Aller au contenu

Data

Documents

Design PDF templates such as invoices and delivery notes. Add variables, preview with test data, publish versions, and generate PDFs in workflows.

Cette page n'a pas encore été traduite. Vous lisez la version originale.

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.

Create a template#

  1. Open the Workflows tab in the sidebar and go to Documents.
  2. On the Templates tab, click New template.
  3. Enter a Name, such as "Invoice", and click Create template. The editor opens.
  4. Under Variables, click Add variable for each value the document needs. Give it a name, a label, and a type.
  5. 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.
  6. Enter sample values under Test payload (JSON) and check the Live preview. Click Render PDF to see the exact PDF.
  7. 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:

TypeInserted asWhat 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}}.

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>

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.

  1. On the Components tab, click New component.
  2. Enter a name using letters, digits, dashes, and underscores, such as company-footer. Optionally pick a category and add a description.
  3. 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.

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.

Astuce: If a document must show values exactly as they were when it was issued, such as the prices on an invoice, store those values on the record when it's created, for example with a computation. Then the PDF reads the stored values, even if prices change later.

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.

Bloqué, ou il manque quelque chose ? Demandez à la communauté.

Demander à la communauté

Afficher en MarkdownSuggérer une amélioration