Español

Lee este artículo en español.

HTML to PDF in n8n: Invoices and Reports with One Node (Free Workflow)

Updated

Short answer: n8n has no built-in "HTML to PDF" node. Add an HTTP Request node that sends your HTML (POST) to https://api.cofferdock.com/pdf with your x-api-key header, set Response Format to File, and the node returns the PDF in the data binary property. Each PDF uses 1 credit, whatever its number of pages.

If you automate with n8n, sooner or later you need a PDF inside a workflow: an invoice for every order, a weekly report, a quote, a ticket or a certificate. You don't need to run Puppeteer, Gotenberg or a server of your own. One HTTP Request node calling the Cofferdock API turns your HTML into a PDF, and the node's output is the PDF file itself.

One thing up front, because people search for it: n8n has no built-in "HTML to PDF" node. The usual way is exactly this: an HTTP Request to an API that renders the HTML.

This is the first page of the real PDF the workflow below returns in n8n:

Invoice PDF generated in n8n with the HTML to PDF workflow

The fastest way: import the invoice workflow

  1. In n8n, create a new workflow and open the ⋯ menu (top right) → Import from URL.
  2. Paste this link: https://cofferdock.com/static/blog/n8n/html-to-pdf.json
  3. Open the HTML to PDF node and replace YOUR_API_KEY with your key.
  4. Click Test workflow. The last node returns the invoice as a PDF file.

You can also download the workflow file and use Import from File, or copy its content and paste it onto the canvas with Ctrl+V. Then replace the Invoice data node with your real trigger: a webhook from your store, a form or a new row in Google Sheets.

What you need

Step by step in the HTTP Request node

The output is the PDF in the data binary property. In Gmail, add an attachment and type data; in Google Drive → Upload, the input data field is also data.

Fill the PDF with data from your workflow

Switch the Body field to Expression and insert values from earlier nodes:

<h1>Invoice {{ $json.number }}</h1>
<p>Bill to: <strong>{{ $json.customer }}</strong></p>
<p>Date: {{ $now.toFormat('yyyy-LL-dd') }}</p>
<table style="width:100%">
  <tr><td>{{ $json.item }}</td><td style="text-align:right">{{ $json.total }}</td></tr>
</table>

If the trigger brings several orders, n8n runs the node once per order and you get one PDF each. A typical flow is Webhook (new order) → HTTP Request (PDF) → Gmail (send to the customer) → Google Drive (archive).

No HTML at all: the invoice template

Prefer not to design the invoice? Send the built-in invoice template with your data as JSON:

{
  "template": "invoice",
  "data": {
    "brand": "Your Company", "number": "INV-1042", "date": "2026-09-15", "client": "Acme Ltd",
    "item1": "Website maintenance", "price1": "€450.00",
    "subtotal": "€450.00", "tax": "€94.50", "total": "€544.50"
  },
  "output": "pdf"
}

All fields are listed at cofferdock.com/templates.json and you can preview the design on the templates page. Texts are escaped, so customer data can't break the layout.

Options you can tweak

OptionDefaultWhat it does
formatA4Page size: A4, A3, A5, Letter, Legal or Tabloid.
landscapefalsetrue for landscape orientation.
margin0Margin in millimeters on all four sides (0 to 100).
scale1Content scale from 0.1 to 2.
print_backgroundtruePrints background colors and images. false for a plainer PDF.
outputpdfpdf returns the file; url returns a temporary download link (15 minutes).

Logos, images and web fonts work with their https://… link inside the HTML or CSS. The document is rendered without running JavaScript, so charts drawn with JS won't appear: use images or the chart tool instead.

Page breaks, headers and long tables

Common errors and how to fix them

What you seeWhyFix
401 Missing x-api-key header / Invalid API keyThe header is missing, misspelled or the key was revoked.Header name exactly x-api-key.
An empty or very short PDFThe Body expression returned nothing, or Body Content Type isn't Raw.Check the Body preview in n8n shows your HTML.
The node returns text instead of a fileResponse Format is still on Autodetect/JSON.Options → Response → Response Format → File.
Colors or backgrounds are missingprint_background is false.Remove it or set it to true.
429 Too many requests or Monthly limit reachedPer-minute limit of your plan, or no credits left this month.Add a Wait node in big loops, or upgrade / buy extra credits.

Prefer to see it in code?

curl -X POST "https://api.cofferdock.com/pdf?format=A4&margin=15" \
  -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, whatever its number of pages. Every Cofferdock tool draws from the same credit pool: merging, watermarking, password-protecting or numbering the PDF afterwards uses the same subscription.

FAQ

Does n8n have a native HTML to PDF node? No. You do it with the HTTP Request node calling the Cofferdock API, which generates the PDF.

Do I need to know how to code? No. Import the workflow, change the texts and connect your trigger. Or use the invoice template and skip the HTML.

Can I password-protect or merge the PDF? Yes, with another HTTP Request to the protect PDF or merge PDF tools, in the same workflow.

Can I generate PDFs in a loop? Yes. n8n runs the HTTP Request once per incoming item and you get one PDF per item.

Related guides

Full reference with every option: HTML to PDF API. No account yet? Create one for free and send your first invoice today.