The n8n node
Operations & fields
The Generate PDF node has one job with two shapes: render one of your templates, or render raw HTML. Every field below matches the shipped node exactly.
Credential: pdfmill API
Every operation authenticates with a pdfmill API credential. It has two fields — API Key (your pk_live_… key from the dashboard) and Base URL (https://api.pdfmill.dev by default; change it only for a self-hosted engine). The key rides n8n's credential system, so it is never a node parameter and never logged. The credential's Test button verifies the key against the engine before you build anything.
Operation: Generate from Template
Render one of your pdfmill templates with data.
| Field | What it is |
|---|---|
| Template Name or ID | Pick a template from the live dropdown, or set an id with an expression. The dropdown lists the templates your key can render — see the templates guide. |
| Data | The values merged into the template's {{variables}}. Defaults to {{ $json }} — the incoming item — so the happy path needs nothing set. |
| Format | PDF (default) or PNG. |
| Put Output File in Field | The binary property that will hold the document. Default data. |
| Options | Page size, orientation, margins, scale, background, file name — see below. |
Operation: Generate from HTML
Render raw HTML you supply — usually an expression that maps HTML from an earlier node. It takes the same Data, Format, Options, and output field. Any {{handlebars}} variables in the HTML are filled from Data (when Data is non-empty).
Options
All options are optional. Margins take a CSS length such as 1cm, 12mm, or 0.5in.
| Option | Type | Default | Notes |
|---|---|---|---|
Page Size | select | A4 | A3, A4, A5, Legal, Letter, or Tabloid. |
Landscape | boolean | false | Rotate to landscape orientation. |
Margin Top / Right / Bottom / Left | string | — | Each a CSS length. Omit to use the template’s own @page margins. |
Print Background | boolean | true | Print background colors and images. |
Scale | number | 1 | Render scale between 0.1 and 2. |
File Name | string | — | Output file name. Defaults to the template name (or “document”) plus the format extension. |
What the node outputs
On success each item carries two things:
- Binary — the rendered document on the field you chose (default
data), with the correct file name and MIME type, ready to chain into an email or upload node. - JSON metadata —
{ success, source, template, format, pages, bytes, durationMs, requestId, fileName, mimeType }.
Continue On Fail is honored
{ success: false, error, code, requestId } down the branch while the good items in the batch still render. Every failure keeps the engine's named error code and a requestId — nothing is swallowed.The node is also usable as an AI tool inside n8n's agent nodes, so an agent can generate a document as a step.