No-code · Updated 2026-12-03
Generate PDFs with n8n
This guide adds PDF generation to an n8n workflow: data from any earlier node goes in, a finished invoice, receipt or report comes out as a link or as binary data you can attach to an email or upload to storage. It uses n8n's built-in HTTP Request node, so it works on n8n Cloud and on self-hosted n8n alike.
A DevilPDF community node for n8n is coming. Until it is published, the HTTP Request node below does the same job.
#What you need
- n8n, Cloud or self-hosted.
- A DevilPDF API key. Sign up, open API keys and create one. It starts with
dp_live_. The free plan includes 500 documents a month.
#1. Save the key as a credential
Storing the key as an n8n credential keeps it out of the workflow JSON, so you can share or export the workflow safely.
- In the HTTP Request node, set Authentication to Generic Credential Type, then Generic Auth Type to Header Auth.
- Create a new credential: Name
Authorization, ValueBearer dp_live_...(the word Bearer, a space, your key). - Name the credential "DevilPDF" so you can reuse it in other workflows.
#2. Configure the HTTP Request node
| Setting | Value |
|---|---|
| Method | POST |
| URL | https://devilpdf.com/v1/render |
| Authentication | Header Auth, the DevilPDF credential |
| Send Body | On |
| Body Content Type | JSON |
| Specify Body | Using JSON |
In JSON, write the body with expressions pulling values from the incoming item. This example assumes the previous node outputs an order with number, customer_name, customer_email and an items array:
{
"template": "invoice",
"data": {
"number": "{{ $json.number }}",
"issue_date": "{{ $now.toFormat('yyyy-MM-dd') }}",
"company": { "name": "Northwind Studio" },
"customer": { "name": "{{ $json.customer_name }}", "email": "{{ $json.customer_email }}" },
"items": {{ JSON.stringify($json.items) }},
"tax_rate": 13,
"tax_label": "HST"
},
"filename": "invoice-{{ $json.number }}"
}JSON.stringifyturns the array into JSON, soitemshas no quotes around it. Each item needsname,quantityandunit_price.- The template calculates the subtotal, tax and total from
items. Do not send totals. - If a text value might contain quotes, use
{{ JSON.stringify($json.customer_name) }}without surrounding quotes. That escapes it properly.
#3. Execute the node
Click Execute step. The output is the document:
| Field | Meaning |
|---|---|
url | Link to the finished PDF |
id | Document id, starting with doc_ |
pages | Page count |
status | succeeded |
Use {{ $json.url }} in later nodes. If the request fails, n8n shows the response, which contains error.message explaining what is wrong.
#4. Get the PDF as binary data
Email and storage nodes want a file. You have two options.
Fetch the link. Add a second HTTP Request node: method GET, URL {{ $json.url }}, and under Options → Response → Response Format choose File. The output has the PDF as binary data in the data property.
Ask for the file directly. Add "output": "file" to the body in step 2 and set the same node's Response Format to File. One request, and DevilPDF stores nothing. You lose the JSON fields (url, pages), but the devilpdf-document-id response header still identifies the document if you turn on Include Response Headers and Status.
Then:
- Send Email or Gmail: under Attachments, enter
data. - Google Drive → Upload: set Input Data Field Name to
data. - S3 / R2 / MinIO: same, upload the
databinary property.
#Many items at once
The HTTP Request node runs once per incoming item, so 200 orders make 200 requests. That is fine for small batches. To keep the workflow fast for large runs:
- Turn on Options → Batching in the HTTP Request node to space out requests.
- Or send one request to
POST /v1/render/batchwith all the documents and awebhook_urlthat points at a Webhook trigger in a second workflow. Each finished document arrives there as adocument.succeededevent with itsurl. See async and batch and webhooks.
#Other documents and languages
Swap "template" for quote, receipt, statement, report, packing-slip or certificate. To see what fields a starter takes, call GET https://devilpdf.com/v1/templates/receipt with the same credential and look at sample_data.
Add "locale": "de" (or "ar", "ja", "pt-BR"...) next to "template" and the labels, dates and money follow the language. Arabic, Hebrew, Persian and Urdu mirror right to left, and fonts for every script are included. Useful when one workflow serves customers in several countries: map the locale from the customer record.