Some test text!

Data Model

Template Generation Data Model

General principles

Each document will have one or more template keys, denoted by the {{ start tag, and }} closing tag -- these are often referred to as "moustache templates" (turn the { around 90 degrees, and it looks like a moustache...). The API should be supplied with a json dictionary, where each template key within the document is a property within the dictionary. The value associated with each key can take a number of forms, as described below.

To see this in practice check out this list of examples .

Allowed formats for values

This data model will be expanded going forward in order to meet customer needs. If you require a specific feature, or don't believe that the current template framework can meet your needs, then please contact us.

Text String

Can be one of:

  • Simple string: "key":"Value Text"
  • Explicit string: In this case the value is a JSON object with the **text**property: "key": {"text":"Value Text"}


An image value is a JSON dictionary with the following required properties:

  • image_url: [string] On web systems this can be a URL, on server/desktop systems it is expected to be a local filesystem path (absolute, or relative to the process working directory).
  • width: [number] Image width, in points (this is the width in the document, not the number of pixels)
  • width: [number] Image width, in points (this is the width in the document, not the number of pixels)

Take a look at the image insertion example to see this in practical usage.

Table row insertion

Table row insertion values are JSON objects, and can only serve as the value for a template key that is in the first row of a table. They have the following required properties:

  • insert_rows: [array of arrays] An array of rows, representing the content to be added. If a table had 3 columns and you wanted to insert two rows within it, insert_rows would expect an array containing two arrays of three items each. The items within the three-member row arrays would be any allowed template value, such as text or an image.

Take a look at the dynamic tables example to see this in practical usage.

Get the answers you need: Support

PDFTron live tech update & run-through: Jan 20th at 11 am PT