TotalBase
Templates

PDF

PDF templates designed with pdfme, rendered by the API or a workflow.

In the admin: Templates › PDF › a template

A PDF template is a page designed with pdfme: fields placed on the page, each filled from your data when the PDF is rendered. Acme renders a Work order PDF with the order's details, its photos and the customer's signature.

The Work order PDF template in the designer: text fields, a table of parts and the signature.
The Work order PDF template in the designer: text fields, a table of parts and the signature.

The designer

Above the designer, the page size: Letter, Legal, Tabloid, receipt widths (58, 80 and 112 mm) or Custom, with Width, Height and Margin. A new template starts on an A4 page. A template whose page is a fixed PDF file keeps that file's size.

Fields you can place: text, multi-variable text, table, list, line, rectangle, ellipse, image, SVG, signature, select, checkbox, radio group, circle mark, date, time, date-time, QR code and barcodes (Code 128, EAN-13, UPC-A).

Each field's name is the key its value comes from. The designer needs a large screen: on a phone or tablet the template opens read-only.

Preview renders the template with each field's sample value, unsaved changes included.

Data

The data is an object with a value per field name. A table takes its rows as a list of lists of text; a multi-variable text takes an object:

{
  "number": "WO-000123",
  "customer": "Hotel Salta Plaza",
  "parts": [["Capacitor 35 µF", "2"], ["Gas R410A", "1 kg"]]
}

Rendering a PDF

  • A workflow: the step Generate PDF from template takes the template and the data and returns a file. See Steps › Documents.
  • The API:
curl -s -X POST https://acme.example/api/totalbase/table/templates/{id}/pdf \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{ "data": { "number": "WO-000123", "customer": "Hotel Salta Plaza" } }' \
  -o WO-000123.pdf

The answer is the PDF, named after the template's slug. It needs READ on the template; errors are TEMPLATE_NOT_FOUND, TEMPLATE_ACCESS_DENIED and TEMPLATE_WRONG_KIND. Copy URL, in the editor's ⋯, copies this address.

A DataView's Print doesn't use templates: it prints the grid or the record as they are.

Next steps