Document definition

Elements

Elements are the most fundamental building blocks in our PDF generation system.

Elements are used inside Blocks, Regions, or directly in Templates to define layout and visual structure.


Characteristics

  • Atomic – Elements are the smallest units in the document model.
  • Composable – Used within Blocks, Regions, or Templates.

Available Element Types

Text

Renders a text string at a specific position or within a layout.

Properties may include:

  • Content (static or dynamic)
  • Font, size, color
  • Alignment
  • Style (bold, italic, etc.)
{
  "type": "text",
  "align": "left",
  "ast": {
    "type": "text-ast",
    "content": [
      {
        "type": "paragraph",
        "content": [
          {
            "type": "text",
            "text": "My awesome text",
            "marks": [
              {
                "type": "bold"
              }
            ]
          },
          {
            "type": "token",
            "attrs": {
              "token": "datasource.field.name"
            }
          }
        ]
      }
    ]
  }
}

Image

Displays an image asset (e.g. logo, icon, photo).

Common properties:

  • Source (local path or embedded data)
  • Size and scaling mode
{
  "type": "image",
  "name": "embedded.image",
  "dimensions": {
    "width": 10.12,
    "height": 10.12,
    "x": 117.13,
    "y": 3.97
  }
}

Table

Displays tabular data with configurable rows and columns.

Common properties:

  • Data source (array of objects)
  • Column headers
  • Cell alignment and styling
  • Optional borders and padding
{
  "type": "table",
  "line": {
    "color": "#000000",
    "thickness": 0.5
  },
  "rowPadding": 1,
  "header": [
    {
      "title": "My title",
      "width": 8,
      "align": "left",
      "bold": true
    },
    ...
  ],
  "footer": [
    ...
  ],
  "margin": {
    "bottom": 5
  },
  "items": {
    "data": "datasource.field.name"
  }
}

Columns

Displays multiple child elements side by side in a horizontal layout.

Common properties:

  • Gap (spacing between columns)
  • Alignment
  • Widths (fixed or auto)
{
  "type": "columns",
  "columnGap": 10,
  "columns": [
    [
      {
        "type": "text",
        ...
      }
    ],
    [
      {
        "type": "text",
        ...
      }
    ]
  ]
}
Previous
Understanding Document Structure
Next
Blocks