Lee este artículo en español.
How to convert HTML to PDF in n8n (with a single node)
If you automate with n8n, sooner or later you need to generate a PDF inside a flow: an invoice, a quote, a report, a ticket. The good news is you don't need to run a server or install odd libraries. With the regular HTTP Request node and the Cofferdock API you can set it up in a minute.
One thing up front, because people search for it: n8n has no dedicated "HTML to PDF" node. You do it with the HTTP Request node calling an API that does the heavy lifting. Here's which one and how, field by field.
What you'll get
You send your document written in HTML (with its CSS, images and fonts) and it returns the PDF, ready for the next step in your flow. No awkward conversions in between: the node's output is already the PDF file.
Common uses in n8n:
- An invoice or a quote in PDF for every new order.
- Automatic reports from the rows of a spreadsheet.
- Personalized tickets, passes or certificates.
- Summaries or contracts ready to email.
What you need
- A Cofferdock account. The free tier gives you 50 uses/month with no card, plenty to test.
- Your API key, created in your dashboard with "+ Create key". It's shown only once, so copy and save it.
- An HTTP Request node in your n8n flow.
Step by step in the HTTP Request node
Add an HTTP Request node and fill it in like this:
- Method:
POST - URL:
https://api.cofferdock.com/pdf - Send Query Parameters: turn it on and add the page size:
format=A4. - Send Headers: turn it on and add two headers:
x-api-keywith your key, andContent-Typewith the valuetext/html. - Send Body: turn it on → under Body Content Type pick
Raw→ in Body paste your HTML (or wire it from a previous step). - Under Options → Response → Response Format pick File.
That's it. The node's output is the PDF as a file, ready to wire into Google Drive, Gmail, Telegram or wherever you need it. One node, done.
A quick example
Say you want a PDF invoice for every incoming order. The flow would be:
- A trigger (a webhook from your store, a form, or a new Google Sheets row) with the order data.
- A Set (or Edit Fields) node that builds the invoice HTML with that order's data.
- The HTTP Request node above, which turns that HTML into a PDF.
- A Gmail node that emails the invoice to the customer (or Google Drive that stores it).
Every order generates its own invoice, with nothing done by hand. That's the kind of repetitive task n8n handles beautifully.
Options you can tweak
Add them as Query Parameters in the same node:
| Option | Default | What it does |
|---|---|---|
format | A4 | Page size: A4, A3, A5, Letter, Legal or Tabloid. |
landscape | false | Set it to true for landscape orientation. |
margin | 0 | Margin in millimeters, the same on all four sides (0 to 100). |
scale | 1 | Content scale (from 0.1 to 2), to enlarge or shrink it. |
print_background | true | Prints backgrounds and colors. Set it to false for a plainer PDF. |
You can use background photos, logos and fonts hosted on the internet by putting their https://… link inside the HTML or CSS. The document is rendered without running JavaScript, so work with HTML and CSS.
Prefer to see it in code?
In case you want to test it quickly outside n8n, the same call with curl:
curl -X POST "https://api.cofferdock.com/pdf?format=A4" \
-H "x-api-key: YOUR_KEY" \
-H "Content-Type: text/html" \
--data-binary "<h1 style='color:#8a5210'>Invoice #1234</h1>" \
-o invoice.pdf
How much does it cost?
Each PDF uses 1 credit from your plan. Every Cofferdock tool draws from the same pool of credits, so you don't have to pay for a separate service for each little thing.
FAQ
Does n8n have a native HTML-to-PDF node? No. You do it with the HTTP Request node calling the Cofferdock API, which is what generates the PDF.
Do I need to know how to code? No. You just fill in the HTTP Request node fields following this guide. The code examples are optional.
Do I get a link or the file? The PDF file directly. With Response Format: File, the next node already receives the PDF, ready to save or send.
Can I control page breaks? Yes, with CSS. Use the page-break-before (or break-before) rule on your elements to force where each page starts.
Can I generate PDFs in a loop? Yes. If the previous node returns several rows, n8n runs the HTTP Request once per row and you get one PDF per item.
Try it yourself
You'll find the full instructions, with copy-paste examples, on the HTML to PDF tool page. And if you don't have an account yet, you can create one for free and build your first flow today.