Skip to content

Templates

Keep the layout on our side and send only the data. Useful when several services produce the same document, or when you don’t want HTML strings in your backend.

Syntax

Templates use Mustache, a small logic-less language:

{{customer.name}}Insert a value, HTML-escaped. Dots reach into objects.
{{{notes_html}}}Insert raw HTML. Only for HTML you trust.
{{#items}}…{{/items}}Repeat for each item in a list, or show the block if the value is truthy.
{{^items}}…{{/items}}Show when the list is empty or the value is false.
{{.}}The current item, in a list of strings.

Format numbers and dates before sending them (e.g. "€1,666.80"). That keeps the PDF identical to what your own system shows and avoids locale surprises.

Render

Built-in starters can be rendered right away by id. This one makes a landscape certificate:

curl https://api.pagenull.dev/v1/templates/certificate/render \
  -H "Authorization: Bearer $PAGENULL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "data": {
    "recipient": "Maria Ivanova",
    "course": "Practical TypeScript",
    "date": "3 November 2026"
  }
}' \
  -o certificate.pdf

Save your own

Create templates in the dashboard with a live preview, or via the API:

POST /v1/templates
{
  "name": "Packing slip",
  "html": "<h1>Order {{order}}</h1><ul>{{#lines}}<li>{{qty}} × {{name}}</li>{{/lines}}</ul>",
  "sampleData": {
    "order": "#1001",
    "lines": [
      {
        "qty": 2,
        "name": "Notebook"
      }
    ]
  },
  "options": {
    "format": "A5",
    "margin": {
      "top": "10mm",
      "bottom": "10mm",
      "left": "10mm",
      "right": "10mm"
    }
  }
}

The response gives you an id like tpl_… to use in /v1/templates/{id}/render. Template HTML and sample data are encrypted at rest with AES-256-GCM. The data you send at render time is never stored.

See the template gallery for ready-made layouts.