Skip to main content
Media elements embed visual and technical content into your document: images, charts, QR codes, code blocks, and LaTeX math equations.

Image

Embeds an image from a URL or uploaded image path.
{
  "type": "image",
  "src": "https://example.com/photo.jpg",
  "width": 400,
  "height": 300,
  "align": "center",
  "caption": "Company headquarters",
  "anchor": "fig-hq"
}

Properties

PropertyTypeRequiredDefaultDescription
typestringYesMust be "image"
idstringNoUnique identifier. Max: 100 chars.
srcstringYesImage URL or uploaded image path (/image/...). Max: 500 chars.
widthnumberNoWidth in px (10–2000).
heightnumberNoHeight in px (10–2000).
alignstringNoAlignment: "left", "center", "right"
captionstringNoCaption for figure numbering (e.g., "Sales chart 2024"). Max: 500 chars.
anchorstringNoAnchor ID for internal references. Pattern: ^[a-zA-Z][a-zA-Z0-9_-]*$. Max: 100 chars.
spacingobjectNoSpacing override with before and after in pt (0–100).
Images with a caption are automatically numbered (e.g., “Figure 1: Company headquarters”). The numbering prefix and style are controlled by defaults.styles.figureCaption. See Defaults — Figure caption style.

Cross-referencing images

Images with a caption and anchor can be referenced in text using internal references:
{
  "sections": [{
    "type": "flow",
    "content": [
      { "type": "image", "src": "https://example.com/diagram.png", "caption": "System architecture", "anchor": "fig-arch" },
      { "type": "text", "text": "As shown in [](#fig-arch), the system consists of three layers." },
      { "type": "text", "text": "Refer to [Figure {num}](#fig-arch) for the full diagram." },
      { "type": "text", "text": "The [architecture diagram](#fig-arch) illustrates the design." }
    ]
  }]
}
The three reference styles: [](#anchor) (auto — shows caption with number), [Figure {num}](#anchor) (template — replaces {num}), and [custom text](#anchor) (custom — shows your text as a link).

Chart

Renders a Chart.js chart as an image. Supports line, bar, pie, doughnut, radar, polar area, scatter, and bubble charts.
{
  "type": "chart",
  "width": 600,
  "height": 400,
  "caption": "Quarterly revenue",
  "config": {
    "type": "bar",
    "data": {
      "labels": ["Q1", "Q2", "Q3", "Q4"],
      "datasets": [
        { "label": "2024", "data": [100, 120, 115, 140] },
        { "label": "2023", "data": [80, 95, 90, 110] }
      ]
    },
    "options": {}
  }
}

Chart element properties

PropertyTypeRequiredDefaultDescription
typestringYesMust be "chart"
idstringNoUnique identifier. Max: 100 chars.
configobjectYesChart.js configuration. See Chart config.
widthnumberNoChart width in px (10–2000).
heightnumberNoChart height in px (10–2000).
alignstringNoAlignment: "left", "center", "right"
captionstringNoCaption for figure numbering. Max: 500 chars.
anchorstringNoAnchor ID for internal references. Max: 100 chars.
spacingobjectNoSpacing override with before and after in pt (0–100).

Chart config

The config object follows the Chart.js configuration format:
PropertyTypeRequiredDescription
typestringYesChart type: "line", "bar", "pie", "doughnut", "radar", "polarArea", "scatter", "bubble"
widthnumberNoRender width in px (50–4000).
heightnumberNoRender height in px (50–4000).
backgroundColorstringNoChart background color.
dataobjectYesChart data with labels and datasets.
optionsobjectNoChart.js options (axes, legend, tooltips, etc.).

Chart dataset

PropertyTypeRequiredDescription
labelstringNoDataset label for the legend.
dataarrayYesData points. Numbers, strings, or {x, y, r} objects (for scatter/bubble).

Variable substitution in charts

Chart data.labels and data.datasets[].data arrays support {{varName}} placeholders. At render time, variable references are resolved:
  • Number variables are substituted as numeric values directly (e.g., {{revenue}}1250.00)
  • Text variables containing a numeric string are parsed to numbers (e.g., "1500"1500)
  • For {x, y} point objects, both x and y fields support variable substitution
{
  "variables": {
    "q1Revenue": { "type": "number", "value": 150000 },
    "q2Revenue": { "type": "number", "value": 180000 }
  },
  "sections": [{
    "type": "flow",
    "content": [{
      "type": "chart",
      "config": {
        "type": "bar",
        "data": {
          "labels": ["Q1", "Q2"],
          "datasets": [{ "label": "Revenue", "data": ["{{q1Revenue}}", "{{q2Revenue}}"] }]
        }
      }
    }]
  }]
}
Default chart colors are configured via defaults.chart.colors and defaults.chart.borderColors. See Defaults — Chart defaults.

QR Code

Generates a QR code image. Supports URL, WiFi, and vCard data types.

URL QR code

{
  "type": "qrcode",
  "qrType": "url",
  "data": { "url": "https://example.com" },
  "size": 200,
  "align": "center"
}

WiFi QR code

{
  "type": "qrcode",
  "qrType": "wifi",
  "data": {
    "ssid": "MyNetwork",
    "password": "secret123",
    "encryption": "WPA",
    "hidden": false
  }
}

vCard QR code

{
  "type": "qrcode",
  "qrType": "vcard",
  "data": {
    "firstName": "John",
    "lastName": "Smith",
    "organization": "Acme Inc",
    "phone": "+1234567890",
    "email": "john@example.com",
    "url": "https://example.com"
  }
}

QR code base properties

PropertyTypeRequiredDefaultDescription
typestringYesMust be "qrcode"
idstringNoUnique identifier. Max: 100 chars.
qrTypestringYesQR data type: "url", "wifi", or "vcard"
dataobjectYesQR code data (varies by qrType).
sizenumberNoQR code size in px (50–1000).
errorCorrectionstringNoError correction level: "L" (7%), "M" (15%), "Q" (25%), "H" (30%).
alignstringNoAlignment: "left", "center", "right"
spacingobjectNoSpacing override with before and after in pt (0–100).
URL data (qrType: "url")
PropertyTypeRequiredDescription
urlstringYesURL to encode. Max: 2000 chars.
WiFi data (qrType: "wifi")
PropertyTypeRequiredDescription
ssidstringYesNetwork name. Max: 32 chars.
passwordstringNoNetwork password. Max: 63 chars.
encryptionstringNoEncryption type: "WPA", "WEP", or "nopass"
hiddenbooleanNoHidden network flag.
vCard data (qrType: "vcard")
PropertyTypeRequiredDescription
firstNamestringNoFirst name. Max: 100 chars.
lastNamestringNoLast name. Max: 100 chars.
organizationstringNoOrganization. Max: 100 chars.
phonestringNoPhone number. Max: 50 chars.
emailstringNoEmail address. Max: 100 chars.
urlstringNoWebsite URL. Max: 200 chars.
addressstringNoAddress. Max: 200 chars.
notestringNoNote. Max: 500 chars.

Code block

Renders a syntax-highlighted code block.
{
  "type": "code",
  "language": "javascript",
  "code": "function hello() {\n  console.log('Hello, world!');\n}"
}

Properties

PropertyTypeRequiredDefaultDescription
typestringYesMust be "code"
idstringNoUnique identifier. Max: 100 chars.
codestringYesSource code content. 1–20000 chars.
languagestringNoProgramming language for syntax highlighting (e.g., "javascript", "python", "sql"), or a diagram language (e.g., "mermaid", "plantuml"). Max: 50 chars.
renderAsImagebooleanNoRender the code block as an image. For diagram languages, defaults to true. Set to false to show diagram source as code.
backgroundColorstringNoBackground color in hex (#RGB, #RRGGBB, or #RRGGBBAA).
widthnumberNoWidth in px (10–2000). Only applies when renderAsImage is true.
alignstringNoAlignment: "left", "center", "right"
captionstringNoCaption for auto-numbering. Code blocks appear in the List of Code Listings; diagram blocks appear in the List of Figures. Max: 500 chars.
anchorstringNoAnchor ID for internal references. Pattern: ^[a-zA-Z][a-zA-Z0-9_-]*$. Max: 100 chars.
spacingobjectNoSpacing override with before and after in pt (0–100).

Captions and anchors

Code blocks support caption and anchor for auto-numbering and cross-references:
{
  "type": "code",
  "language": "typescript",
  "code": "interface Config {\n  apiUrl: string;\n  timeout: number;\n}",
  "caption": "Configuration interface",
  "anchor": "code-config"
}
Code blocks with a caption are automatically numbered (e.g., “Listing 1: Configuration interface”) and appear in the List of Code Listings. The numbering prefix and style are controlled by defaults.styles.codeCaption. See Defaults — Code caption style. Default code block styling is configured via defaults.styles.code. See Defaults — Code style.

Diagrams

Code blocks with a supported diagram language are automatically rendered as images in the exported document.

Mermaid example

{
  "type": "code",
  "language": "mermaid",
  "code": "graph TD\n    A[Start] --> B{Decision?}\n    B -->|Yes| C[Action 1]\n    B -->|No| D[Action 2]\n    C --> E[End]\n    D --> E",
  "caption": "System flowchart",
  "anchor": "fig-flowchart",
  "align": "center"
}
When the language is a supported diagram type, the code content is rendered as a PNG image. Diagrams with a caption are auto-numbered as figures (e.g., “Figure 1: System flowchart”) and appear in the List of Figures.

Supported diagram languages

Languagelanguage valueDescription
Mermaid"mermaid"Flowcharts, sequence diagrams, class diagrams, Gantt charts, and more
PlantUML"plantuml"UML diagrams (class, sequence, activity, use case, etc.)
GraphViz"graphviz" or "dot"Graph and network visualizations
Structurizr"structurizr"C4 architecture diagrams
BlockDiag"blockdiag"Simple block diagrams
SeqDiag"seqdiag"Sequence diagrams
ActDiag"actdiag"Activity diagrams with swimlanes
NwDiag"nwdiag"Network topology diagrams
PacketDiag"packetdiag"Packet/protocol header diagrams
C4 with PlantUML"c4plantuml"C4 architecture model using PlantUML syntax
DBML"dbml"Database markup language for ER diagrams
Ditaa"ditaa"ASCII art to diagram conversion
ERD"erd"Entity-relationship diagrams
TikZ"tikz"LaTeX-based technical drawings
UMlet"umlet"UML diagrams
Vega"vega"Declarative data visualizations
WireViz"wireviz"Wiring harness and cable documentation

Rendering diagram source as code (renderAsImage=false)

Set renderAsImage to false to display the diagram source code as a regular code block instead of rendering it as an image:
{
  "type": "code",
  "language": "mermaid",
  "code": "graph TD\n    A --> B\n    B --> C",
  "renderAsImage": false,
  "caption": "Mermaid source code",
  "anchor": "code-mermaid-src"
}
When renderAsImage is false on a diagram code block, the block is treated as a regular code listing. If it has a caption, it appears in the List of Code Listings instead of the List of Figures.
The global default for renderAsImage can be set via defaults.styles.code.renderAsImage (default: true). The element-level property always overrides the global default.

Math (LaTeX)

Renders a block-level LaTeX math equation as a standalone element.
Math is only supported as a block-level element. Inline math within paragraphs is not currently supported.
{
  "type": "math",
  "latex": "E = mc^2",
  "align": "center"
}
Block-level equation:
{
  "type": "math",
  "latex": "\\int_{0}^{\\infty} e^{-x^2} dx = \\frac{\\sqrt{\\pi}}{2}",
  "align": "center"
}

Properties

PropertyTypeRequiredDefaultDescription
typestringYesMust be "math"
idstringNoUnique identifier. Max: 100 chars.
latexstringYesLaTeX math expression. 1–5000 chars.
alignstringNoAlignment: "left", "center", "right"
renderAsImagebooleanNoRender math as image for better cross-format compatibility.
spacingobjectNoSpacing override with before and after in pt (0–100).
Default math styling is configured via defaults.styles.math. See Defaults — Math style.

Complete example

{
  "document": { "type": "pdf", "size": "A4" },
  "defaults": {
    "chart": { "colors": ["#4BC0C0", "#FF6384", "#36A2EB"] },
    "styles": {
      "figureCaption": { "fontSize": 9, "fontStyle": "italic", "prefix": "Fig." }
    }
  },
  "sections": [
    {
      "type": "flow",
      "content": [
        { "type": "h1", "text": "Technical Report" },
        {
          "type": "image",
          "src": "https://example.com/architecture.png",
          "width": 500,
          "align": "center",
          "caption": "System architecture overview",
          "anchor": "fig-arch"
        },
        { "type": "text", "text": "The architecture shown in [Fig. 1](#fig-arch) consists of three layers." },
        {
          "type": "chart",
          "caption": "Performance benchmarks",
          "config": {
            "type": "line",
            "data": {
              "labels": ["Jan", "Feb", "Mar", "Apr"],
              "datasets": [{ "label": "Requests/s", "data": [1200, 1500, 1800, 2100] }]
            }
          },
          "width": 500,
          "height": 300
        },
        { "type": "h2", "text": "Implementation" },
        {
          "type": "code",
          "language": "typescript",
          "code": "async function render(doc: Document): Promise<Buffer> {\n  const result = await engine.process(doc);\n  return result.toBuffer();\n}"
        },
        { "type": "h2", "text": "Mathematical Model" },
        { "type": "math", "latex": "f(x) = \\sum_{n=0}^{\\infty} \\frac{f^{(n)}(a)}{n!}(x-a)^n", "align": "center" },
        { "type": "h2", "text": "Contact" },
        {
          "type": "qrcode",
          "qrType": "vcard",
          "data": { "firstName": "John", "lastName": "Smith", "email": "john@example.com" },
          "size": 150,
          "align": "center"
        }
      ]
    }
  ]
}