Import it from @grafloria/renderer.
tsinterface SvgExportOptions
Properties
| Name | Type | Default | Description |
|---|---|---|---|
theme? | Theme | The theme whose values get baked into the output. MUST be the theme the tree was rendered with — it is the source of every --grafloria-* value the live stylesheet would have supplied. Defaults to LIGHT_THEME. | |
scale? | number | Multiplies the SVG's width/height (its intrinsic size) while the viewBox stays put — so the picture is unchanged, just rendered larger. This is what makes a 2x PNG a 2x PNG. | |
backgroundColor? | string | Painted as a full-viewBox rect behind everything. Default: transparent. | |
foreignObject? | ForeignObjectMode | What to do with <foreignObject> subtrees. Default 'serialize'. | |
captureForeignObject? | (vnode: VNode) => string | undefined | Supply the live HTML inside a foreignObject (browser-side callers). | |
customNodes? | readonly CustomNodeCapture[] | CUSTOM-NODE CONTENT — the widgets an HTML-layer node paints, which the VNode tree does not contain and cannot contain (the renderer emits an empty <g> for those nodes; the page paints a raw HTML host that is a SIBLING of the SVG). | |
htmlFallback? | HtmlFallbackMode | What to do with a custom node that could only be captured as HTML. Default 'foreignObject'. Whatever you choose, it is REPORTED in warnings — a widget that cannot make it into the file faithfully never does so quietly. | |
embedFontCss? | string | CSS emitted verbatim into a <style> inside <defs>. THE font seam: pass an @font-face whose src is a data: URI and the exported file carries its own glyphs. We do not fetch, subset or embed fonts for you — that is a deliberate boundary, not an oversight. | |
embedFonts? | FontSource[] | Fonts to EMBED as base64 @font-face rules — the built form of the embedFontCss seam. Both are honoured; embedFontCss is appended after these. | |
fitToContent? | boolean | Fit the viewBox to the CONTENT — the union box of everything the tree actually draws (labels, ports and arrowheads included), not the root's own viewBox. | |
padding? | number | Margin around the fitted content box, in world units. Default 20. | |
includeIds? | Iterable<string> | Export ONLY these node/link ids. The tree is pruned to them (not merely cropped — an un-selected node outside the viewBox is invisible but its markup, and its labels, would still be in the bytes) and the box is fitted around them. | |
viewBox? | Rectangle | Use this exact viewBox and fit nothing. Wins over fitToContent. | |
maxSize? | number | Cap on the output's intrinsic size, per side, in px. Default 4000. The scale is REDUCED to fit rather than the picture being cropped — see clampOutputSize. | |
minSize? | number | Floor on the output's intrinsic size, per side, in px. Default 1. | |
xmlDeclaration? | boolean | Prepend the <?xml …?> prolog. Default false (an inline <svg> must not have one). | |
embedModel? | DiagramDocumentEnvelope | Embed this document envelope in the SVG's <metadata>, making the exported file an EDITABLE artifact: re-import it and get the diagram back, losslessly. |
Was this page helpful?