How to Generate PDFs in an n8n Workflow

Install the verified ImaginePDF node in n8n, pick a design, map your fields, and every run of the workflow returns a finished PDF as a binary file.

Jagadeesh
Jagadeesh
September 12, 20267 min read
On this page

An n8n workflow can end with a real document. Not a link to a template, not an HTML string you still have to render, but a finished PDF sitting on the output item, ready for the next node to attach or upload.

That is what the ImaginePDF node does. You design the document once on a canvas, mark the parts that change, and the node fills them in every time the workflow runs.

Tap to enlarge
A webhook trigger feeding the ImaginePDF Generate PDF node, which passes a binary PDF to an email node

One node in the middle of the workflow. What comes out the other side is a file.

One node in the middle of the workflow. What comes out the other side is a file.

The node is verified by n8n, so it installs from the Community Nodes screen on a self-hosted instance and on Cloud alike.

Install the node

In n8n, open Settings → Community Nodes and click Install. Enter the package name:

n8n-nodes-imaginepdf

An instance owner does this once. After that, everyone on the instance finds ImaginePDF in the nodes panel.

Create the credential

The node authenticates with a workspace API key.

In ImaginePDF, open Settings → API Keys and create one. It starts with pc_live_ and is shown a single time, so copy it before closing the dialog.

Tap to enlarge
An API key created in ImaginePDF settings and pasted into the ImaginePDF API credential in n8n, which reports a tested connection

The key is shown once in ImaginePDF. n8n verifies it the moment you paste it.

The key is shown once in ImaginePDF. n8n verifies it the moment you paste it.

Back in n8n, add an ImaginePDF API credential and paste the key. n8n checks it right away by listing a single design, so a green result means both the key and the workspace are reachable. The key belongs to a workspace rather than to your login, which is what you want for something that runs unattended.

Design the document and bind its variables

The node carries no template of its own. It renders one of the designs already in your workspace, so the document itself is made in the ImaginePDF editor: place the text, the table, the logo, the QR code, and get it looking right with sample content.

Then pick the parts that change and bind each one to a variable with a name like invoice_no or client_name. Those names are the contract between the design and the workflow. If you have not bound variables before, the template guide covers it from the beginning.

Map the fields

Add the ImaginePDF node and choose Generate PDF. The Design dropdown lists the designs in your workspace, so there is no id to look up or paste.

Under Field Values, add one row per variable. The key is the variable name from the design. The value is whatever you map in from the trigger or an earlier node:

{{ $json.customer.name }}
Tap to enlarge
Variables bound on an invoice design matched one to one with the key and value rows of the node's Field Values collection

The key on the left of each row is the variable name you bound in the editor. Nothing else has to line up.

The key on the left of each row is the variable name you bound in the editor. Nothing else has to line up.

Three things worth knowing before you run it:

  • A variable you leave out renders empty. It does not fall back to the sample content you designed with, so a blank value in your data stays blank on the page.
  • The key is the variable name, not the element name. Rename a variable in the editor and the row has to follow.
  • An image field takes an uploads:<id> or assets:<id> reference. Raw image data and data URIs are not accepted there.

Use the PDF downstream

Every output item carries two things.

The file, as binary data in the field named data by default. Change that under Put Output File in Field if the next node expects a different name. Point Gmail or Send Email at it to attach the PDF, Google Drive at it to upload, or Write Binary File at it to drop the file on disk. There is no download step in between.

JSON metadata, namely downloadUrl, filename, expiresIn and status. Reach for downloadUrl when a link is more useful than a file, say a Slack message or a row written to a database. It is presigned, so it opens without an API key, and it expires after about an hour. Do not store it as a permanent address.

Each generated PDF costs one credit.

Running more than one

The node runs once per input item. Feed it ten items and ten PDFs come back, each on its own output item, so a Schedule trigger reading rows out of a sheet or a database needs no looping construct around it.

For a few hundred documents in one go, the workflow is the wrong shape. Upload the rows as a dataset in ImaginePDF and export the whole run as a zip instead. The bulk guide walks through that path, which is built for volume.

What is not in this version

Worth saying plainly, because the API supports all three and the node does not yet:

  • No image upload. You cannot push a file into the design from the workflow. Image fields need a reference that already exists in the workspace.
  • No batch operation. One PDF per item, as above.
  • No design search. The dropdown loads your first hundred designs, without paging or filtering.

Troubleshooting

The credential will not save. n8n tests the key by listing a design, and a failure there is almost always a mistyped or truncated key, or one that has been revoked. Keys are shown once, so create a fresh one if you are not certain you copied the whole string.

The design is missing from the dropdown. The list comes from the workspace the key belongs to. With more than one workspace, check that the key was created in the one holding the design. The list also stops at a hundred entries.

The PDF comes out with blanks. An unmapped or empty field renders empty by design. Compare the key on each Field Values row against the variable name in the editor; they have to match exactly, including case.

The next node cannot find the file. It is reading the wrong binary field. The node writes to data unless you changed Put Output File in Field.

Where to go next

The node is listed at n8n.io/integrations/imaginepdf and published as n8n-nodes-imaginepdf on npm. The integration page has the short version of everything above.

If you would rather not install anything into n8n, the same generation runs through the REST API with a single POST, and through the Zapier app if that is where your automations already live.

Related guides