Barcodes
Barcodes are written two ways: inline within paragraph text, as a [barcode, …] shortcode, or at exact coordinates inside an svg, as a barcode shape. Both are rendered into the PDF or DOCX output. The API supports 64 symbologies spanning retail, logistics, healthcare, postal, automotive, and specialty industrial use cases. Each symbol is drawn as vector geometry (a DOCX claiming Office Open XML Strict, which has no vector shape for it, carries a picture at print resolution), with the quiet zone, bar height and printed size its own standard states, and each payload is checked against the symbology's own rules.
Live catalog
Every supported symbology with a sample rendering. Open the Template tab to see the source JSON, or Try in Playground to edit it live. The same catalog also lives as a standalone tutorial at Barcode Catalog.
- Output
- Template
- Data
Inline syntax
[barcode, type, payload]
[barcode, type, payload, width|height]
[barcode, type, payload, width|height, slot, slot, ...]
The first three slots are positional; only type and payload are required. The rest are recognised by their shape and may come in any order.
| Slot | Description |
|---|---|
type | Symbology name, exactly as the schema spells it (e.g. qrcode, code128, gs1-128, hibc-dm). One name per symbology, with no aliases: any other name is refused, and a name written in another letter case is refused with the right spelling named. See Symbologies. |
payload | The data to encode. A payload holding a comma is written in quotes, "DESC=Machines, under 10 kg", or the comma ends it. |
width|height | Optional size of the marks in points; either may be left out. With neither, the symbol is drawn at the printed size its standard states — see Sizing. |
#RRGGBB | Optional ink colour for the bars (e.g. #1A1A2E). |
#RRGGBB|#RRGGBB | Optional ink, then the background behind the symbol. With no background the symbol is transparent. |
key=value | An encoder option: hrt, gs1, ec, square or quiet. See Options. |
Printing a shortcode without running it. A doubled opening bracket is a literal one, so [[barcode, code128, X] prints as text.
Quick start
Plain QR for a tracking link
{ "p": "Scan to track: [barcode, qrcode, https://track.docpayload.example/DOC-2026-04521, 100|100]" }
Code 128 shipping label
{ "p": "[barcode, code128, DOC-2026-04521, 200|50]" }
GS1-128 with bracketed Application Identifiers
{ "p": "[barcode, gs1-128, [01]04150123456789[17]270630[10]A4521, 220|50]" }
Bracketed Application Identifiers need no escaping inside the tag.
Brand-tinted QR
{ "p": "[barcode, qrcode, https://docpayload.example, 80|80, #1A1A2E]" }
Barcodes in table cells
{
"table": {
"widths": [2, 1, 2],
"rows": [
[
{ "p": "[b]Shipment[/b]" },
{ "p": "[b]Service[/b]" },
{ "p": "[b]Tracking[/b]" }
],
[
{ "p": "DOC-CA-2026-04521" },
{ "p": "Express" },
{ "p": "[barcode, code128, DOC-CA-2026-04521, 120|35]" }
]
]
}
}
Barcodes in columns layouts
{
"columns": {
"widths": [2, 1],
"gap": 20,
"rows": [
[
{ "p": "[b]Shipment Details[/b]" },
{ "p": "From: Toronto, ON" },
{ "p": "To: San Francisco, CA" }
],
[
{ "p": "[barcode, qrcode, https://track.docpayload.example/DOC-CA-2026-04521, 100|100]" },
{ "p": "[fontsize, 8]Scan to track[/fontsize]" }
]
]
}
}
Barcodes inside svg
Inside an svg, a barcode shape places a symbol at exact coordinates beside the other shapes: the centre of a seal, the corner of a label, an edge strip. It takes the same symbology names as the shortcode, in spec.type, and the payload in spec.code:
{
"svg": {
"viewBox": [150, 100],
"title": "Product code 977251777100",
"children": [
{ "rect": { "x": 0, "y": 0, "width": 150, "height": 100, "rx": 6, "style": "labelCard" } },
{ "barcode": { "x": 10, "y": 8, "width": 68, "spec": { "type": "ean13", "code": "977251777100" }, "style": "ink" } }
]
}
}
| Key | Description |
|---|---|
x, y | Left and top edge of the symbol's marks, in the svg's coordinates. Default 0. |
width | Width of the marks; the quiet zone is added around them. Given alone, the height follows the symbol's proportions. |
height | Height of the marks; given alone, the width follows the symbol's proportions. With neither, the symbol is drawn at its standard's nominal size. |
spec | Required: { "type": …, "code": … }, and any of the encoder options hrt, gs1, ec, square and quiet. code takes $data and $item tokens. |
style | The named style whose fill is the ink. |
The shape takes the shortcode's encoder options as keys of its spec, with the same names: "hrt": true prints an EAN's digits in the slots its guard bars leave, "gs1": true encodes GS1 data, and so on. It has no background of its own: it is drawn in its style's fill, over whatever the svg draws beneath it, so draw a light shape under it when the symbol needs one.
Barcodes with data references
Barcode payloads can be populated from $data references at render time:
{ "p": "[barcode, qrcode, $data.shipment.trackingUrl, 80|80]" }
{ "p": "[barcode, code128, $data.shipment.trackingId, 180|45]" }
Data Matrix shape
Data Matrix has square and rectangular sizes. A box with equal sides, or no box at all, asks for a square symbol; any other box allows a rectangle, which the encoder picks only where it is the smaller symbol for the payload. square=true forces a square whatever the box. Data Matrix has a fixed aspect ratio, so a box of another shape than the symbol it produces is reported (see What gets reported).
{ "p": "Square: [barcode, datamatrix, DOC-2026-0001, 80|80] Forced square: [barcode, datamatrix, DOC-2026-0001, 80, square=true]" }
What's next
- Symbologies — all 64 types by family, with the X-dimension each is drawn at and the options each honours.
- Options & defaults — sizing, quiet zones, the human-readable line, colours, encoder options and what the report says.