@polotno/svg-export
v0.7.0
Published
Convert plain Polotno JSON into SVG with embedded fonts in browsers or Node.js with a DOM implementation
Readme
@polotno/svg-export — Polotno JSON to SVG
Convert one page of Polotno design JSON into SVG markup. The default output embeds its fonts.
Works without the editor. Pass plain Polotno design JSON from any source.
Runtime: Browser first. Node.js requires a DOM implementation such as jsdom.
License: Non-production use is free, with no time limit. Production use requires a valid Polotno subscription. Read the license.
Install
npm install @polotno/svg-exportUsage
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.
