0.1.1 • Published 6d ago
@polotno/svg-export
Licence
SEE LICENSE IN LICENSE.md
Version
0.1.1
Deps
3
Size
74 kB
Vulns
0
Weekly
0
@polotno/svg-export
Export Polotno designs to SVG.
Usage
import { jsonToSVG } from '@polotno/svg-export';
// one page per SVG document — pass the page you want
const json = store.toJSON();
const svg = await jsonToSVG(
{ ...json, pages: [json.pages[0]] },
{
fontEmbedding: 'inline', // 'inline' (default) embeds fonts, 'none' skips
// overflow behavior for text taller than its box: 'change-font-size'
// (default) shrinks the font to fit — the polotno-node export default;
// 'resize' keeps the authored size (SVG never clips; unsupported values
// like 'ellipsis' fall back to the default).
textOverflow: 'change-font-size',
}
);
jsonToSVG accepts plain design JSON — no editor or store required.
elementHook({ dom, element }) lets you post-process each element's node.
Node
The exporter is browser-first and needs a DOM (DOMParser, canvas text
measurement). In Node, run it under jsdom —
the same setup this package's own test suite uses. For full-fidelity
rendering in Node (real Chromium), use
polotno-node.