Skip to content

Document Generator

This node generates a document (PDF or HTML) by combining a template designed in the Templates section with the workflow payload. Rendering uses no external dependencies or paid services.

It takes the template (by template_id or inline), resolves {{data.field}} variables against the payload and draws the document. It always saves a copy to disk and, optionally, persists the document to serve it via a tokenized URL.

FieldTypeRequiredDescription
template_idTemplate selectorNo*Template saved in the Templates section. The + creates a new one.
output_formatSelectNopdf (default), html or both.
outputSelectNourl (default): persist and return a link. base64: embed the document.
filenameTextNoFile name. Supports variables, e.g. sheet_{{data.reference}}.
ttl_hoursNumberNoLink expiry (URL mode only).
template_jsonTextarea (advanced)No*Inline block template, if not using a saved one.

* Requires template_id or template_json.

{
"document": {
"url": "http://your-engine/d/doc/<token>",
"token": "<token>",
"path": "/local/path/to/file.pdf",
"file_url": "http://your-engine/download/cli_2/file.pdf",
"filename": "sheet_R-100.pdf",
"mimetype": "application/pdf",
"bytes": 24567
},
"filename": "sheet_R-100.pdf",
"path": "/local/path/to/file.pdf"
}
  • document.url — a /d/doc/:token link served by the engine (not the app). Keeps the workflow state small.
  • document.path — local path of the generated file (for email attachments, FTP, etc.).
  • document.file_url — direct download URL of the file on disk.
{ "filename": "sheet_R-100.pdf", "mimetype": "application/pdf", "pdf_base64": "JVBERi0x...", "path": "/local/path/..." }

The template is a JSON with page, theme, header, footer and a blocks array. Block types: titleBlock, section, fieldGrid, table, text, image, qr, divider, pageBreak. Any block supports when (conditional). Full detail in the Document Generator guide.

{
"page": { "size": "A4", "orientation": "portrait", "margins": 40 },
"header": { "brand": "{{data.company}}", "title": "INVOICE", "refLine": "No. {{data.number}}" },
"footer": { "left": "Generated · {{now}}", "right": "Page {page} of {pages}", "pageNumbers": true },
"blocks": [
{ "type": "section", "title": "Customer" },
{ "type": "fieldGrid", "columns": 2, "fields": [
{ "label": "Customer", "value": "{{data.customer}}" },
{ "label": "Tax ID", "value": "{{data.tax_id}}" }
]},
{ "type": "table", "from": "{{data.lines}}", "zebra": true, "columns": [
{ "header": "Item", "path": "item", "width": 5 },
{ "header": "Amount", "path": "amount", "align": "right", "width": 1 }
]}
]
}
Next nodeUse case
sendMailAttach the document (via path) or link url.
httpReturn document.url as an API response.
ftp / s3Upload the generated file using document.path.
dataStoreStore the document link to look it up later.
  • The node runs in the queue worker. After engine changes, restart the worker so it picks up the new version.
  • document.url points to the engine (where the /d/doc route lives), not the app.
  • Images: JPEG is embedded; the QR is drawn as a vector.
  • htmlTemplate — HTML rendering with variables (no native PDF).
  • barcodeGenerator — generates barcode/QR images.
  • sendMail — sends the document by email.