SVG
Draw shapes, text, and images at precise coordinates — diagrams, charts, icons, seals, decorative chrome. You author them the way you already know: as SVG. Element names and properties mirror SVG — cx/cy/r, x1/y1/x2/y2, d, fill, stroke, viewBox — so an SVG snippet transfers with minimal translation, and a real .svg file can be pasted as markup as it is. Everything renders as native vector in both PDF and DOCX, with zero raster images; where Word cannot carry something, the element's section says so.
Live example
A real-world architecture diagram: a hexagon for the edge service, rounded rectangles for compute, ellipse-on-rectangle cylinders for databases, color-coded connectors. Open the Template tab to see the JSON.
- Output
- Template
- Data
The svg block
An SVG graphic is a Content item with an svg block — a viewBox plus a list of children. It reads like an <svg> root element:
{
"svg": {
"viewBox": [0, 0, 24, 24],
"children": [
{ "path": { "d": "M12 2 C8 2 5 5 5 9 c0 5 7 13 7 13 s7-8 7-13 c0-4-3-7-7-7 Z", "style": "pin" } },
{ "circle": { "cx": 12, "cy": 9, "r": 2.5, "style": "hole" } }
]
}
}
| Property | Type | Default | Description |
|---|---|---|---|
viewBox | [W, H] or [minX, minY, W, H] | auto from children | Coordinate extents as a numeric array — the same convention as table / columns widths. Omit to derive the tight box from the children (paths and curves included). |
width | number | viewBox scale | Rendered display width in points. The viewBox stays the coordinate space the children are drawn in; width scales the graphic to this size. Omit to render at 1 unit = 1 point. |
height | number | derived from aspect | Rendered display height in points. Give one of width/height to scale uniformly (the other follows the viewBox aspect), or both. |
children | array | — | Drawing elements (see below). |
title | string | — | Accessible name for the whole graphic (screen readers, tagged-PDF /Alt, DOCX drawing title). An accessibility claim requires title or desc. |
desc | string | — | Longer accessible description. |
src | string | — | SVG markup to draw, written inline as a string, in place of children. See SVG markup. |
file | string | — | An .svg file beside the document to draw, in place of children. |
caption | string | — | A caption announced with the graphic (markup allowed), drawn where the style's captionSide puts it and tagged as the figure's Caption. |
style | string | — | The block's style: margins, alignment (justifySelf), border, padding, background, captionSide, float, position, the keys an image block takes. Wins over a style named on the node beside svg. |
Give an svg one source: children, src or file. With two, the first in that order is drawn and the render reports the others as unread; with none, it draws nothing and says so.
Each child is { "<element>": { …props } } — one drawing element keyed by its name, exactly as SVG nests elements inside <svg>. Every element carries a style reference into document.styles for its fill / stroke / etc.
Coordinates are box-relative, top-left origin — x grows right, y grows down. A 4-number viewBox ([minX, minY, W, H]) shifts the origin the same way SVG does, so negative author-coordinates land inside the box.
Keep coordinates local. The graphic is its own coordinate box — never reach for page-absolute positions inside it. With
viewBoxomitted, the box is derived from the children, so a single stray page-sizedyinflates the derived box and the whole graphic shrinks toward nothing. Position the block on the page like any other content item; position children within the box.
Pasting a real icon as JSON? Keep its
ddata andviewBoxexactly as-is, convert theviewBoxstring to an array, and addwidthfor the size you want — e.g. a0 0 1024 1024glyph with"width": 24renders as a 24 pt icon. No coordinate math. Or skip the conversion and paste the whole file as markup.
SVG markup
src takes SVG markup as a string, and file names an .svg file in the document's folder (a relative path inside it; anything else is refused). The markup is read into the same element tree the JSON form builds, so its text stays real, selectable, shaped text, its presentation attributes become styles, and anything it asks for that cannot be drawn is reported rather than dropped:
{
"svg": {
"src": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><circle cx=\"12\" cy=\"12\" r=\"10\" fill=\"#0F766E\"/></svg>",
"width": 48,
"height": 48,
"title": "Status: active"
}
}
{ "svg": { "file": "floor-plan.svg", "width": 400, "height": 250, "title": "Ground floor plan" } }
The root element's own width and height are honoured, units included (1in, 96px, 25.4mm), when the node gives no size; to size it from the node, give both width and height. The elements read are svg, g, a, use, rect, circle, ellipse, line, path, polygon, polyline, text and image. Markup is untrusted input and is read without a DTD, so no entity is expanded and no external file is fetched through it. $data tokens in markup resolve as they do in the JSON form.
Placing the block
An svg block is placed like an image block, by its style: justifySelf (CSS Box Alignment 3's justify-self: start, center, end, left, right) sets where a drawing narrower than its container stands, margins space it, and the same style can give it a border, padding or background like any block:
{ "svg": { "viewBox": [160, 160], "width": 120, "style": "sealBlock", "title": "Company seal",
"children": [ { "circle": { "cx": 80, "cy": 80, "r": 78, "style": "seal" } } ] } }
{ "styles": { "sealBlock": { "justifySelf": "center" },
"badgeBlock": { "justifySelf": "end", "marginTop": 12, "captionSide": "bottom" } } }
To place a shape inside its own box, shift it with a g translate.
Elements
Every element renders as native vector in PDF and DOCX; the few things Word cannot carry are noted where they apply.
- Output
- Template
- Data
The vocabulary is standard SVG plus a few DocPayload conveniences:
| Category | Elements | |
|---|---|---|
| SVG primitives | rect, circle, ellipse, line, polygon, polyline, path | Standard SVG. |
| SVG content | text, textPath, image | Standard SVG. |
| SVG grouping | g, use | Standard SVG — group under one transform; instantiate a reusable symbol. |
| Shape shortcuts (extension) | arc, triangle, diamond, pentagon, hexagon, octagon, plus, parallelogram, trapezoid, rightArrow, leftArrow, upArrow, downArrow, chevron | Convenience shapes SVG can express only via hand-computed polygon points or path arcs. Each fits a width × height box you supply; the vertices are derived for you. |
| Barcode (extension) | barcode | A render-time barcode generator — no SVG equivalent. Encodes a payload (often $data-bound) as native vector. |
SVG vocabulary + DocPayload extensions. Everything in the first three rows is standard SVG. The shape shortcuts and
barcodeare DocPayload additions layered on top — they live alongside the SVG elements in the samechildren, so you never leave the SVG model to reach them. Usepath/polygonwhen you want strict SVG; reach for the shortcuts andbarcodewhen they save you the arithmetic.
The path / textPath elements accept raw SVG d strings, making them the most flexible primitive — anything you can draw in SVG (Beziers, arcs, compound paths, decorative flourishes) transfers directly. See the Patterns Gallery tutorial for a full reference of decorative compositions (mandala, sunburst, Greek key, Lissajous, guilloché).
Drawing elements
Each element is { "<name>": { …props } }. Every element carries a style reference into document.styles.
Geometry primitives
Rectangle
{ "rect": { "x": 100, "y": 100, "width": 150, "height": 80, "rx": 6, "ry": 6, "style": "card" } }
rx / ry are optional corner radii — omit them for square corners.
The style's width and height size the rectangle over its own, as CSS sizes an SVG rect. minWidth, maxWidth, minHeight and maxHeight do not bound it, as browsers do not, and no other shape takes width or height: the render report says so of each.
Circle
{ "circle": { "cx": 200, "cy": 100, "r": 30, "style": "node" } }
Ellipse
{ "ellipse": { "cx": 200, "cy": 100, "rx": 55, "ry": 6, "style": "dbCap" } }
Shape shortcuts (extension)
triangle, diamond, pentagon, hexagon, octagon, plus, parallelogram, trapezoid. All take x, y, width, height; the vertices fit inside that box. (In strict SVG these would be a <polygon> with hand-computed points.)
{ "triangle": { "x": 0, "y": 0, "width": 80, "height": 80, "style": "shape" } }
{ "diamond": { "x": 110, "y": 0, "width": 80, "height": 80, "style": "shape" } }
{ "pentagon": { "x": 220, "y": 0, "width": 80, "height": 80, "style": "shape" } }
{ "hexagon": { "x": 330, "y": 0, "width": 80, "height": 80, "style": "shape" } }
{ "octagon": { "x": 0, "y": 100, "width": 80, "height": 80, "style": "shape" } }
{ "plus": { "x": 110, "y": 100, "width": 80, "height": 80, "style": "shape" } }
{ "parallelogram": { "x": 220, "y": 100, "width": 80, "height": 80, "style": "shape" } }
{ "trapezoid": { "x": 330, "y": 100, "width": 80, "height": 80, "style": "shape" } }
Directional arrows follow the same rule — rightArrow, leftArrow, upArrow, downArrow, chevron. The orientation is encoded in the name; the renderer adjusts the vertex math.
{ "rightArrow": { "x": 0, "y": 0, "width": 90, "height": 60 } }
{ "leftArrow": { "x": 110, "y": 0, "width": 90, "height": 60 } }
{ "upArrow": { "x": 220, "y": 0, "width": 60, "height": 90 } }
{ "downArrow": { "x": 290, "y": 0, "width": 60, "height": 90 } }
{ "chevron": { "x": 360, "y": 0, "width": 80, "height": 60 } }
Group g
Groups children under a shared transform and a cascaded default style, exactly like SVG's <g>. Children draw in the group's local coordinates.
| Property | Type | Description |
|---|---|---|
children | array | Child elements, any of the vocabulary on this page — groups nest. |
translate | [tx, ty] | Offset in points. |
rotate | number | Rotation in degrees. |
scale | [sx, sy] | Scale factors, non-negative. To mirror, use transform (below). |
transform | string | A CSS transform list, applied after translate, rotate and scale: "skewX(20deg)", "rotate(45deg) scale(2)", "matrix(1, 0, 0.4, 1, 0, 0)". Angles carry their unit. |
clip | object | Clips the group's shapes and images to one outline, in the group's coordinates: { "circle": … }, { "ellipse": … }, { "rect": … } (rounded by rx/ry) or { "path": { "d": … } }, geometry only. Text inside is drawn whole, and the render reports it. |
viewBox | [W, H] or [minX, minY, W, H] | The extent the group's drawing occupies, used to size the svg where its shapes cannot be measured (text, for one). It clips nothing. |
style | string | Named style cascaded to children that declare none. |
Transforms compose as CSS Transforms 2 composes them: translate, rotate and scale, then the transform list from left to right.
Mirroring. scale takes no negative factor, but the transform list does: "translate(200, 0) scale(-1, 1)" flips a group left to right about the right edge of a 200-wide box, and matrix(-1, 0, 0, 1, 200, 0) is the same flip.
{ "g": { "transform": "translate(200, 0) scale(-1, 1)", "children": [
{ "rightArrow": { "x": 0, "y": 0, "width": 90, "height": 60, "style": "arrow" } }
] } }
A group clipped to a disc, its two bands cut by the same circle:
{ "g": { "clip": { "circle": { "cx": 60, "cy": 60, "r": 50 } }, "children": [
{ "rect": { "x": 0, "y": 0, "width": 120, "height": 60, "style": "sky" } },
{ "rect": { "x": 0, "y": 60, "width": 120, "height": 60, "style": "sea" } }
] } }
DOCX note. The DOCX writes each shape's outline already transformed, so translate, rotate, scale, skew and a mirror draw in Word as they do in the PDF. Two things are not carried, and the render reports each: svg text that a rotation or a skew turns, and a group's
clip.
Labeled nodes (group a shape + label)
A diagram node — a shape with a centered label — is a g group: the shape plus a text centered in the same box. Children draw in the group's local coordinates, so translate places the node and the group's style cascades to children that declare none (here, the shape inherits the node fill while the label keeps its own white-text style).
{ "g": {
"translate": [30, 85],
"style": "node",
"children": [
{ "hexagon": { "x": 0, "y": 0, "width": 110, "height": 50 } },
{ "text": { "x": 0, "y": 25, "width": 110, "baseline": "middle", "text": "API Gateway", "style": "nodeLabel" } }
]
} }
Centre the label vertically with baseline: "middle" and y at the box's mid-height (here y: 25 for a 50-tall box) — no y = height/2 − fontSize/2 arithmetic. When the same node recurs across a diagram (the common case), define it once as a symbol and use it with per-instance data — see order-lifecycle-states.json and org-chart.json.
Live example — architecture-diagram.json (a hexagon edge node as a g, plus four arch-node symbols instantiated via use).
Polygon
Closed polygon defined by N points. Useful for stars, badges, custom flowchart shapes. Auto-closed (last vertex back to first).
{
"polygon": {
"points": [
{ "x": 100, "y": 10 },
{ "x": 140, "y": 40 },
{ "x": 125, "y": 90 },
{ "x": 75, "y": 90 },
{ "x": 60, "y": 40 }
],
"style": "star"
}
}
Polyline
An open run of connected segments — same vertex list as polygon, but not closed back to the first point. Use it for zigzags, open paths, sparkline strokes, and axis ticks where a closing edge would be wrong.
{
"polyline": {
"points": [
{ "x": 10, "y": 60 }, { "x": 50, "y": 20 },
{ "x": 90, "y": 60 }, { "x": 130, "y": 20 }, { "x": 170, "y": 60 }
],
"style": "trace"
}
}
Lines and arcs
Line
{ "line": { "x1": 50, "y1": 50, "x2": 200, "y2": 150, "style": "connector" } }
Arc (extension)
Sweep from startAngle to endAngle (degrees, CCW from +x) around (cx, cy). A shortcut for a path with an A command when you'd rather give a center and angles than compute arc endpoints.
{ "arc": { "cx": 200, "cy": 200, "r": 60, "startAngle": 0, "endAngle": 180, "style": "arc" } }
Paths & text on path
Path
Arbitrary SVG path data via the d attribute. Supports the standard SVG commands: M/m (moveto), L/l (lineto), H/h / V/v (horizontal/vertical lineto), C/c / S/s (cubic Bezier + smooth), Q/q / T/t (quadratic Bezier + smooth), A/a (elliptical arc), Z/z (close path). Strokes and/or fills based on which color properties the style supplies (stroke → stroke, fill → fill, both → fill+stroke).
{ "path": { "d": "M 0 50 Q 100 0 200 50 T 400 50", "style": "wave" } }
Compound paths with holes — set fillRule on the element (beside d) to evenodd so overlapping subpaths cut holes instead of filling solid. This is what icons pasted from the common icon sets rely on to keep their counters. fillRule lives on the element, not the style, because winding is intrinsic to the path data. PDF honors it fully; Word renders nonzero winding and logs a diagnostic (holes may fill).
{ "path": { "d": "M20 20H180V100H20Z M60 40H140V80H60Z", "fillRule": "evenodd", "style": "icon" } }
Full circle as two semicircular arcs:
{ "path": { "d": "M 100 6 A 94 94 0 0 1 100 194 A 94 94 0 0 1 100 6", "style": "outerRing" } }
textPath
Flows text along a path with per-glyph rotation. The path itself is not drawn — pair with a path element using the same d if you want a visible curve too.
| Property | Type | Description |
|---|---|---|
d | string | SVG path data (same syntax as path). |
text | string | Text to flow; supports Shortcodes ([b], [i], [u], [s], [sub], [sup], [mark], [color], [fontsize], [caps], [font, Family], …) and multi-line via [br] / [br, n] — svg text never wraps, so explicit breaks are the line boundaries and each line aligns independently. Shaped at render time — complex scripts join/stack correctly (see Multi-script text and seals). |
textAnchor | enum | start (default) · middle · end — where the run sits along the path relative to startOffset. |
startOffset | number | string | Distance along the path before the run's anchor: a number in viewBox units, or a percentage of the path's own length ("50%"). |
side | enum | left (default) or right, which reverses the path and puts the text inside a circle. The style's textRise lifts the text off the path. |
textLength | number | The run's exact reach along the path, from its first glyph to its last, in viewBox units: a ring of text that must close where you measured it. |
lengthAdjust | enum | spacing (default) widens or narrows the gaps between letters to reach textLength; spacingAndGlyphs stretches the letters too. |
style | string | Text style. |
{
"textPath": {
"d": "M 24 100 A 76 76 0 0 1 176 100",
"text": "OFFICIAL · [color, #7A1F2E]STATE CORPORATION COMMISSION[/color]",
"textAnchor": "middle",
"style": "sealTopText"
}
}
On an arch centred on its arc with textAnchor: middle, the seal-ring case, a string wider than the arc scales down uniformly to fit it, and the render reports the percentage. Everywhere else a glyph whose midpoint falls past either end of the path is not drawn, as SVG specifies, and the render reports the overhang. Size arcs generously all the same: a fitted legend reads best when the shrink is slight.
The arc can sit at any angle — d is free-form, so an arc spanning any portion of a circle places its text there (textAnchor: middle with startOffset: "50%" centers the string on the arc's midpoint). The horizontal-endpoint semicircles in the seal examples are a convention, not a constraint.
Content
Text
{ "text": { "x": 150, "y": 200, "text": "Section header", "style": "label" } }
When width is set, (x, y) is the top-left of a text box and the style's textAlign centers/right-aligns the text within that box. Without width, the anchor is the alignment pivot — center alignment pivots on (x, y), right alignment ends at it.
{ "text": { "x": 0, "y": 10, "width": 180, "text": "EDGE", "style": "laneHeader" } }
Vertical anchoring — baseline. By default y is the top of the text. Set baseline to change what y means vertically (it's an element field, beside x/y):
baseline | y is the… |
|---|---|
(omitted) / hanging / textBeforeEdge | top of the text |
middle / central | vertical center — centers the text on y |
alphabetic | baseline (SVG's own default) |
textAfterEdge / ideographic | bottom of the text |
baseline: "middle" is the clean way to vertically center a label in a shape — write y at the box's mid-height instead of computing y = height/2 − fontSize/2. PDF places it exactly from font metrics; Word approximates via the text box's offset.
The same choice can live in the text's style instead, as CSS writes it: dominantBaseline (auto, alphabetic, ideographic, middle, central, mathematical, hanging, textTop, textBottom, textBeforeEdge, textAfterEdge), and SVG's alignmentBaseline, read when dominantBaseline is absent. See Typography.
{ "text": { "x": 55, "y": 25, "baseline": "middle", "text": "42", "style": "gaugeValue" } }
Set fontFamily on the text style to use an embedded font, and switch fonts mid-string with the [font, Family] Shortcode — both text and textPath are shaped at render time (see Multi-script text and seals).
Fit text to a fixed slot — textLength on the text element forces the rendered text to an exact width (viewBox units): a variable-length name always filling the same badge slot. lengthAdjust picks the mechanism: spacing (default — the gaps between glyphs stretch or squeeze) or spacingAndGlyphs (the glyphs scale too, for a condensed/expanded look). Single-line only — it is ignored with a diagnostic when the text contains [br].
{ "text": { "x": 4, "y": 15, "baseline": "middle", "text": "MAXIMILIENNE DE LONGCHAMP",
"style": "name", "textLength": 172, "lengthAdjust": "spacingAndGlyphs" } }
Image
{ "image": { "x": 50, "y": 30, "width": 100, "height": 40, "href": "images/logos/acme.png" } }
Aspect-ratio fitting — preserveAspectRatio on the image element controls how a photo meets a box of a different shape: meet letterboxes it (whole image visible, centered), slice covers the box (centered, overflow cropped). Omit it to stretch. Prefer an explicit meet/slice whenever the box and photo proportions differ — that is also the only mode guaranteed identical across both output formats.
Barcode (extension)
Place any supported barcode symbology at exact coordinates — PDF417, DataMatrix, QR, Code128, Code39, MaxiCode, and the 2D specialty codes. There is no SVG equivalent: the encoder runs at render time and emits native vector, so the encoded value can be a $data.* reference.
{
"barcode": {
"x": 80, "y": 56,
"width": 40, "height": 40,
"spec": { "type": "datamatrix", "code": "$data.credential.payload" }
}
}
| Property | Type | Description |
|---|---|---|
x, y | number | Left and top edge of the symbol's marks in local coordinates. |
width, height | number | Size of the marks in points; the quiet zone the symbology requires is added around them. Given alone, the other follows the symbol's proportions; neither given, the printed size its standard states. |
spec.type | string | Symbology — datamatrix, qrcode, pdf417, code128, code39, aztec, maxicode, microqr, rmqr, micropdf417, dotcode, hanxin, code16k, codablockf, ultracode, gridmatrix, upnqr, and all 1D linear types. See Symbologies. |
spec.code | string | The payload to encode. Supports $data.* and $item.* references. |
spec.hrt, spec.gs1, spec.ec, spec.square, spec.quiet | The barcode tag's encoder options, by the same names. | |
style | string | The named style whose fill is the ink the bars are drawn in. |
spec takes exactly type and code. The encoder options of the shortcode (hrt, gs1, ec, square, quiet) and its background colour are not available here: an svg barcode is drawn with its standard's defaults, in its style's fill, on whatever the svg draws beneath it. See Barcodes inside svg.
This is the positioned barcode primitive — distinct from the [barcode, …] Shortcode which renders inline with text flow. Use this form when you need the barcode at a precise location alongside other elements (the center of a seal, a corner of a form, an edge sidebar).
Live examples — official-seal.json (PDF417 verification record next to control numbers), achievement-certificate.json (DataMatrix at the visual center of an academic seal), graduation-certificate.json (a QR verification code in the diploma's corner, linked to its verify page), stock-certificate.json (DataMatrix verification badge), void-check.json (edge-mounted Code128 watermark).
Multi-script text and seals
text and textPath are shaped with the same engine that shapes flowing paragraphs — at render time. Arabic and Hebrew join into their contextual forms and set right-to-left, Devanagari builds conjuncts, Thai stacks vowel and tone marks, and Chinese/Japanese/Korean render from a CJK family. Choose the face with fontFamily on the text style, and switch fonts per run with the [font, Family] Shortcode. Each textPath ring can therefore carry a different script — which is what makes a multi-script seal possible.
Mixed-script text is zero-config: a line mixing Latin with Arabic, Hebrew, Indic or Thai splits into per-script slices, each routed to a covering font, and right-to-left segments — numbers included — order correctly with no declaration. Keep each textPath to a single script: text on a path shapes with one script's rules, so give each ring its own script, exactly as the seal examples do.
Live examples — world-languages-proclamation.json (one seal carrying Arabic, Latin, Greek and Devanagari on concentric textPath rings around a CJK character) and multilingual-device-guide.json (Latin + CJK outer rings, Devanagari + Thai inner rings around a bold CJK character). See Custom Fonts for the shaping and subsetting details.
SVG styles
SVG elements use a different set of keys than paragraph styles. Use the keys below: box keys (backgroundColor, border, padding, margins) do not apply to shapes, and the render reports them. Paint a shape with fill, and highlight svg text with [mark].
Naming aligns with SVG presentation attributes. Same semantics as SVG, JSON-style camelCase.
Each element resolves independently — like SVG. A shape takes its own
style; a shape with none inherits the enclosingg's style; with neither, it takes SVG's initial paint: filled black, with no stroke. So an outline needsfill: "none"beside itsstroke, and astrokeWidthalone draws no outline. Paint set on one child never leaks to a later sibling, so you don't need defensive resets likestrokeDasharray: [0]oropacity: 1— an element that doesn't declare a dash simply has none. To share appearance across siblings, put them in agwith a groupstyle.
| Property | Applies to | Description |
|---|---|---|
fill | shapes, text | Interior fill — a color, none, or a gradient object. Default black. |
stroke | shapes, lines, paths, text | Border / line / stroke color, or none. Default none. On svg text it outlines the glyphs after the fill. |
strokeWidth | shapes, lines, paths | Stroke width in points. |
strokeDasharray | shapes, lines, paths | Dash pattern as number array: [on, off] for simple dash, [a, b, c, d, …] for dash-dot, [0.5, 2.5] paired with strokeLinecap: "round" for dotted. Omit for a solid line — dashes never leak between elements. |
strokeDashoffset | paths | Starting offset into the dash pattern (defaults to 0). |
strokeLinecap | shapes, lines, paths | butt (default) / round / square — line-end shape. Combined with strokeDasharray, round turns tiny on-segments into round dots instead of square pixels. |
strokeLinejoin | paths | miter (default) / round / bevel — corner join style at polyline vertices. |
strokeMiterlimit | paths | How far a mitred corner may reach, as a multiple of the stroke width, before it is bevelled: 1 or more, default 4. |
vectorEffect | shapes, lines, paths | nonScalingStroke keeps the stroke width constant when the shape is inside a scaled symbol — a hairline stays a hairline no matter what size the use renders at, instead of thickening with the geometry. |
dropShadow | shapes, paths, text | Object { dx, dy, blur, color, opacity }, defaults 2, 2, 3, #000000, 0.4 — drop shadow behind the shape (dy positive drops it downward; blur 0 is a hard edge; opacity 0–1). Card lift, seal relief, badge depth. Only the painted parts cast a shadow, so an unfilled shape shadows its outline. Edge softness differs slightly between the two formats. |
opacity | all | 0.0–1.0 transparency, applied to fill and stroke. |
fillOpacity | shapes | 0.0–1.0 transparency of the fill only. Overrides opacity for the fill — a translucent fill under an opaque stroke (the standard highlight-box idiom). |
strokeOpacity | shapes, lines, paths | 0.0–1.0 transparency of the stroke only. Overrides opacity for the stroke. |
color | text, textPath | Text fill color. On a shape, color is not its fill. |
fontSize | text, textPath | Text size in points. |
fontWeight / fontStyle | text, textPath | Weight (bold, normal, 100…900) and style (italic, normal). |
fontFamily | text, textPath | Font family for embedded custom fonts. |
letterSpacing | text, textPath | Inter-character tracking in points (positive widens, negative tightens). |
textAlign | text | start / end / left / center / right / justify — domain is the text's width when set, the anchor point otherwise. |
textJustify / textAlignLast | text | With a width, a justified line is stretched to it: textJustify: "interCharacter" spreads the letters, textAlignLast: "justify" stretches the last line too. In the DOCX, inter-character justification falls back to the word spaces. |
textRenderingMode | text, textPath | fill (default) / stroke / fillstroke / invisible / fillclip / strokeclip / fillstrokeclip / clip; the …clip modes clip what the same svg draws after the text to its letters. |
transform | all shapes, text | A CSS transform list, such as "skewX(20deg)" or "matrix(1, 0, 0.4, 1, 0, 0)", applied to the shape's coordinate system. |
rotate | all shapes, text | Rotation in degrees about transformOrigin, positive clockwise. |
transformOrigin | all shapes, text | The point rotate turns about, as CSS writes it: "left top", "100% 50%", "10pt 0". Default "50% 50%", the centre. |
clipPath | all shapes, text (not textPath) | Clips the shape to circle(), ellipse(), inset(), polygon() or path("…"), laid over the shape's box, lengths in points or percentages; none clips nothing. Not carried by the DOCX, which reports it. See Paint. |
Svg text also takes the run keys a paragraph takes: textDecoration, textRise, wordSpacing, horizontalScaling, fontKerning, fontSynthesis, direction, writingMode and textOrientation, as Typography describes them. fillOpacity, strokeWidth, strokeDasharray and vectorEffect apply to text as they do to a shape.
{
"styles": {
"card": { "fill": "#1E40AF", "stroke": "#1E3A8A", "strokeWidth": 0.5 },
"cardLabel": { "fontSize": 9, "fontWeight": "bold", "color": "#FFFFFF", "textAlign": "center" },
"connector": { "stroke": "#16A34A", "strokeWidth": 1.5 }
}
}
Clickable shapes
Make a drawn shape a live link — a CTA button, a logo pointing at your site, a diagram node opening a reference — with link on the element (the flattened form of SVG's <a href> wrapper):
{ "rect": { "x": 0, "y": 8, "width": 160, "height": 42, "rx": 8, "style": "cta",
"link": "https://docpayload.com/docs" } }
link is available on rect, circle, ellipse, polygon, path, text, and image (where it complements href, the image source). The whole shape becomes the clickable region in both formats (for polygon/path, the shape's bounding box). Only absolute http, https, and mailto URLs are accepted — anything else is refused with a diagnostic and the shape renders without the link.
In a header or footer the shape still draws, but links there are not clickable in PDF. Put linked graphics in the body.
Clipping an image to a shape
Circular staff photos, shaped frames, cover portholes — set clip on the image element with inline geometry (same viewBox coordinates as the image):
{ "image": { "x": 150, "y": 0, "width": 120, "height": 120, "href": "images/photos/portrait.jpg",
"clip": { "circle": { "cx": 210, "cy": 60, "r": 58 } } } }
The clip shape is one of circle, ellipse, rect, or path (arbitrary outline via SVG path data), positioned in the same viewBox coordinates as the image itself. Draw a ring or frame after the clipped image to dress the rim. Both formats crop to the exact same outline; keep the clip within the image box.
To clip several shapes at once, give their g a clip. To clip a single shape or a piece of text to a CSS basic shape laid over its own box, use the style key clipPath ("circle()", "inset(6 round 10)", "polygon(50% 0, 100% 100%, 0 100%)"), which any block takes as well; see Paint.
Markers — arrowheads on lines and polylines
Every connector, callout and dimension line needs an arrowhead — declare it on the element instead of hand-computing polygons:
{ "line": { "x1": 100, "y1": 27, "x2": 218, "y2": 27,
"markerEnd": { "shape": "triangle", "size": 7 }, "style": "connector" } }
linetakesmarkerStart/markerEnd;polylineaddsmarkerMid(one marker per interior vertex — data-point dots on a trace).shapeistriangle(arrowhead, tip on the vertex),diamond, orcircle(centered on the vertex);sizeis the length/diameter inviewBoxunits (default 6).- The marker fills with the element's style
strokecolor — no separate style needed. markerStartpoints backward along the line, somarkerStart+markerEndon one line is a double-headed dimension arrow.
Both output formats draw identical heads. For a custom head beyond the built-in three, compose a reusable symbol.
Gradient fills
fill also accepts a gradient object — linear or radial — rendered as native vector shading in both formats:
{
"styles": {
"ribbon": { "fill": { "linearGradient": { "angle": 180, "stops": [
{ "offset": 0, "color": "#0F766E" },
{ "offset": 1, "color": "#134E4A" }
] } } },
"glow": { "fill": { "radialGradient": { "stops": [
{ "offset": 0, "color": "#FDE68A" },
{ "offset": 0.6, "color": "#F59E0B" },
{ "offset": 1, "color": "#B45309" }
] } } }
}
}
linearGradient—anglein degrees as CSSlinear-gradient()measures it:0points ↑, angles turn clockwise,90points →,180points ↓ (the default),225points ↙.stopsis an ordered list of{ offset, color }whereoffsetis a0–1fraction along the gradient andcolortakes the usual hex/name vocabulary. A stop colour with alpha (rgba(42, 14, 5, 0),#2A0E0580) fades the ramp there, so a scrim from transparent to dark over a photo is one style. Two to 256 stops, in order of offset; add more for multi-band ribbons.radialGradient— radiates from the shape's center (offset: 0) out to its corners (offset: 1). Samestopsform.
Gradients map to the shape's own bounding box, so one named style tints a rect, a circle, a path, or a polygon alike — and each shape in a group gets its own gradient extent. Combine freely with stroke (the outline stays a solid color) and fillOpacity. A gradient spanning several separate shapes as one wash isn't expressible — merge them into a single path, or give each shape its own gradient.
DOCX note. An svg holding text, a picture or a link, or one in a text box or a signature's box, is written as VML, whose fill carries one alpha at each end of the ramp: the primary colour's in
opacityand the secondary's ino:opacity2, as ISO/IEC 29500-4 19.1.2.5 defines them. Word 16 applies the two the other way about when a fill lists its colours, so a translucent gradient in such an svg fades the other way in Word. The file follows the standard (see the standards decide); every other svg carries each stop's alpha in DrawingML, which Word draws as the PDF does.
Data binding inside SVG
$data.* / $item.* references resolve inside an svg block in the value slots: text.text, textPath.text, image.href, barcode.spec.code, a shape's link and its style name ("style": "band-$data.palette" picks one of the styles declared) — including inside nested g groups. Geometry and the values inside a style are not data-bound; to make an instance's position or size dynamic, declare it as a symbol and pass x / y / width / height / rotate through use.params.
Symbols & reuse — use
Draw a graphic once, instantiate it many times. A symbol is a document whose content is a single SVG graphic; a use element stamps it into another graphic at a destination box, scaling it from the symbol's viewBox and binding per-instance data — exactly like SVG's <use>.
Declaring a symbol
A symbol is an ordinary document file with a metadata.name handle and an SVG payload. The name is what authors reference — it's independent of the file name and folder.
{
"component": {
"metadata": { "name": "quality-seal" },
"styles": {
"sealOuter": { "stroke": "#10243E", "strokeWidth": 2 },
"sealGrade": { "fontSize": 46, "fontWeight": "bold", "color": "#10243E", "textAlign": "center" }
},
"content": [
{
"svg": {
"viewBox": [150, 150],
"children": [
{ "circle": { "cx": 75, "cy": 75, "r": 72, "style": "sealOuter" } },
{ "text": { "x": 0, "y": 45, "width": 150, "text": "$data.grade", "style": "sealGrade" } }
]
}
}
]
}
}
$data.grade is a placeholder filled in per instance (see Data Binding). The symbol's named styles travel with it — they resolve in whatever document uses it.
Instantiating with use
Inside any SVG graphic, a use element names the symbol and gives a destination box. width/height scale the symbol from its viewBox; params supplies that instance's values.
{
"svg": {
"viewBox": [472, 175],
"children": [
{ "use": { "name": "quality-seal", "x": 16, "y": 12, "width": 150, "height": 150, "params": { "grade": "A" } } },
{ "use": { "name": "quality-seal", "x": 206, "y": 27, "width": 120, "height": 120, "params": { "grade": "B" } } },
{ "use": { "name": "quality-seal", "x": 372, "y": 39, "width": 100, "height": 100, "params": { "grade": "A+" } } }
]
}
}
One definition, three sizes, three grades — no duplicated geometry. The rings, text, and any nested shapes scale as a unit.
- Output
- Template
- Data
use field | Meaning |
|---|---|
name | The symbol's metadata.name (the handle authors write). |
id | Optional GUID pin; wins over name when both are present. |
version | Pins the reference to a catalog version (the symbol's metadata.version). Omit to track the latest published version. A pin that matches nothing is reported as unresolved rather than quietly resolving to another version; trailing zeros are optional (1.2 matches 1.2.0). |
x / y | Destination top-left, in the host graphic's coordinates. |
width / height | Destination size; the scale is derived against the symbol's viewBox. Give only one and the other follows the symbol's proportions, so the symbol scales evenly from its x/y corner, whatever preserveAspectRatio says. |
params | Per-instance values bound to the symbol's $data.* placeholders. May also carry x/y/width/height/rotate to make this use's own geometry dynamic (e.g. "params": { "width": "$data.columnWidth" } }) — a value here wins over the literal field of the same name. |
rotate / transform | Optional transforms applied to the instance: a rotation in degrees about the box's centre, and a CSS transform list such as "skewX(15deg)". |
preserveAspectRatio | How the symbol meets a box of other proportions: none (default) stretches it, meet fits it whole and centres it, slice fills the box, centres it and crops the overflow. |
style | Named style cascaded to the instance's shapes that declare none. |
Transforms compose as CSS Transforms 2 composes them (translate, rotate and scale, then the transform list). Symbols can use other symbols; nesting is depth-limited with a cycle guard.
DOCX note. In Word output a
usebecomes a nested group whose shapes are written already transformed, as ag's are; svg text a rotation or skew turns is not carried, and the render reports it.
Patterns gallery — paths, curves, and textPath
A second live example exercising the more decorative end of the API: SVG path data, quadratic and cubic Bezier curves, arcs, textPath (text flowed along a curve), polygon shapes, and overlapping compositions. Useful as a reference when authoring seals, ornamental borders, math/geometry illustrations, or anything where the layout language is "place these curves exactly here."
- Output
- Template
- Data
When something doesn't draw
Malformed path data, an unresolvable image, an undeclared font family, or text in a script no font covers all degrade politely: the element is skipped and the render continues. Opt into Rendering Diagnostics to see each failure named in-document, as a marker at the element that raised it and in the end-of-document appendix.
What's next
- Watermarks — page chrome behind the body: any content node, including full SVG graphics, repeated across pages.
- Tables — tabular layouts that flow with paragraphs.
- Columns — multi-column flow layouts.