Data
Documents
Design PDF templates such as invoices and delivery notes. Add variables, preview with test data, publish versions, and generate PDFs in workflows.
A document template is the design of a PDF, such as an invoice, a quote, a delivery note, or a certificate. You lay it out once with placeholders for the values that change. A workflow fills in the placeholders and creates the PDF.
Templates are versioned. You edit a draft, and publishing freezes it as a numbered version. A workflow can always use the latest published version, or stay on a specific one, so documents keep looking the same until you decide to switch.
Reusable pieces, such as a letterhead, a footer, or a terms block, are components that any template can include.
Templates, components and library images belong to the database you are in. Switching database shows that database's documents. A new database starts without them; install a module that contains the templates, or create them again. The brand — logo, colours and address — stays shared by the organization, and a template reads the current brand when it is rendered.
Create a template#
- Open the Workflows tab in the sidebar and go to Documents.
- On the Templates tab, click New template.
- Enter a Name, such as "Invoice", and click Create template. The editor opens.
- Under Variables, click Add variable for each value the document needs. Give it a name, a label, and a type.
- Write the layout in the HTML pane and the styling in the CSS pane. Click a variable in the sidebar to insert it where your cursor is.
- Enter sample values under Test payload (JSON) and check the Live preview. Click Render PDF to see the exact PDF.
- Click Publish, optionally add a Publish note about what changed, and confirm.
A template that has never been published shows Draft only, and workflows can't use it yet.
Variables and placeholders#
Placeholders are variable names in double curly braces, such as {{customer_name}}. Each variable has a type, which decides what clicking it inserts:
| Type | Inserted as | What it does |
|---|---|---|
| string | {{customer_name}} | Shows the text as it is. |
| number | {{formatNumber quantity 2}} | Shows the number with two decimals. |
| currency | {{formatCurrency total "EUR"}} | Shows the amount as euros. |
| date | {{formatDate invoice_date "YYYY-MM-DD"}} | Shows the date in the given pattern. |
| boolean | {{#if paid}} … {{/if}} | Shows the content in between only when the value is true. |
| array | {{#each lines}} … {{/each}} | Repeats the content in between for each item. |
| object | {{customer}} | A nested value. Show one of its fields with a dot, such as {{customer.city}}. |
| image | {{image photo width=30 height=30}} | Shows a photo from a Files column or an uploaded file. |
Change the format in the inserted text to suit you, for example a different currency code or date pattern.
Repeat rows for a list#
Use an array variable for the lines of an invoice or order. Inside the repeated block, refer to each item's fields by name:
<table>
<tr><th>Item</th><th>Qty</th><th>Price</th></tr>
{{#each lines}}
<tr>
<td>{{description}}</td>
<td>{{formatNumber quantity 0}}</td>
<td>{{formatCurrency price "EUR"}}</td>
</tr>
{{/each}}
</table>Logos and images#
A document can show the workspace logo, a named image from the library, or a photo that belongs to one record.
Set the logo, the mark, the letterhead, the primary color, and the address under Settings, then Brand. In a template, click Logo in the sidebar, or write:
{{image brand.logo width=40}}
<p>{{brand.address_block}}</p>The logo is not frozen when you publish. A later render uses the logo that is current then.
Named images live in the Images list in the template sidebar. Give the image a name, upload it, then click it to insert {{asset "name" width=40 fit="contain"}}. Publishing pins that image: replacing it later does not change documents that were already published. A new publish picks up the replacement.
For a product photo, add an image variable and connect it in the workflow to a file on the record. The first image in a Files column is used. Sizes are in millimetres. fit="contain" keeps the whole image inside the box. fit="cover" fills the box and may crop the edges.
A missing image is left as an empty frame and the preview lists a warning. Add on_missing="error" when a missing image should stop the document instead.
Images addressed by a web address are not loaded. Upload them into the brand or the image library.
Page settings#
Click Page to set the Size (A4, A5, Letter, Legal, or Tabloid), the Orientation (portrait or landscape), and the Margins (mm).
Components#
Components are reusable blocks shared across templates.
- On the Components tab, click New component.
- Enter a name using letters, digits, dashes, and underscores, such as
company-footer. Optionally pick a category and add a description. - Write the block's HTML and CSS, then publish it.
To use a component, click it under Components in a template's sidebar, or type {{> company-footer}} where it should appear. Change the component once and every template that includes it follows.
Several languages#
One template can print its labels in several languages, such as an invoice in the customer's language or a bilingual CMR consignment note.
- Write each label as
{{t "invoice_title"}}instead of the text itself. - Open the Translations tab next to Test data, click Add language, and fill in each label. Paste whole translation files in the JSON view:
{ "en": { "invoice_title": "Invoice" }, "de": { "invoice_title": "Rechnung" } }. - Add a
languagevariable, such asde, and connect it in the workflow, for example to the customer's language. Click Preview in the Translations tab to see a language in the preview.
{{t2 "invoice_title"}} prints the same label in the secondary_language, for forms that show two languages, and prints nothing when no second language is given. {{t "invoice_title" lang="fr"}} always prints French. A label that is missing in a language falls back to English, then to any language that has it. Labels are published with each version and travel with the template in a blueprint.
Versions#
- Publish freezes the current draft as the next version, such as v1, v2, and so on.
- History lists the published versions. Revert to this version loads an older version back into the draft, so you can publish it again.
Create PDFs in a workflow#
Add a Generate Document step to a workflow and pick the template. The step gets one input for each of the template's variables. Connect them to values from the record, then choose what to do with the PDF, such as storing it in a record's Files column.
Under Version, keep latest to always use the newest published version, or pick a specific version to keep using it after the template changes. See File and document steps for the details.
Plan a document#
For each document, write down the template, the record it's made from, its variables, and where the PDF goes: stored on a record, uploaded to another system, or both.
Discussions about this page
Stuck, or found something missing? Ask the community.