BlogAutomation Tutorials

How to Generate PDFs in n8n from HTML or Templates

Generate PDFs in n8n with the Orshot node and a template or Gotenberg or a hosted HTML to PDF API or Google Docs. Tested side by side with workflow JSON

n8n has no HTML to PDF node, so to generate a PDF in n8n you send data to a renderer: the Orshot node with a template, Gotenberg in Docker, a hosted HTML to PDF API or a Google Docs export.

I ran the same invoice rows through both main paths in n8n 2.48 on December 2, 2026. The Orshot workflow needed 3 nodes and no code. The Gotenberg workflow needed 5 nodes and about 25 lines of HTML and CSS.

The real choice is who maintains the document. With Orshot you design it once in a visual editor and n8n only sends field values. With Gotenberg you write and maintain the invoice as HTML and CSS.

TL;DRWhich n8n PDF setup fits your job? Pick what you start from:
Gotenberg + HTTP Request nodeFree and open source. You run the Docker container.Read why
WayYou sendRuns on n8n Cloud
1. GotenbergAn index.html fileOnly if Gotenberg is reachable from the internet
2. Hosted HTML APIAn HTML stringYes
3. Orshot nodeField values like bill_to_nameYes, verified node
4. Google Docs exportText for {{placeholders}}Yes, built-in nodes

Does n8n Have a PDF Node?

n8n has no node that turns HTML into a PDF. The Convert to File node writes CSV, HTML, ICS, JSON, ODS, RTF, text and spreadsheet files, but not PDF. The Extract from File node reads PDFs; it doesn't write them.

Two built-in nodes can still hand you a PDF:

  • Google Drive exports a Google Doc as a PDF (part 4 below).
  • APITemplate.io is a built-in node with a Create PDF operation, tied to an APITemplate.io account.

Everything else is a community node. n8n Cloud only installs verified community nodes, such as the Orshot node. Unverified ones, like Puppeteer nodes, need a self-hosted n8n.

I checked this in the n8n docs and the node panel on December 2, 2026.

1. Convert HTML to PDF in n8n with Gotenberg

Gotenberg is a free, open source (MIT) Docker image that prints HTML to PDF with Chromium. Version 9.11.1 came out on December 1, 2026.

Pick this if you already write the PDF as HTML, you self-host n8n, and you want a free HTML to PDF step.

Step 1: Start Gotenberg next to n8n

docker run -d --name gotenberg -p 3000:3000 gotenberg/gotenberg:9.11.1

Put it on the same Docker network as n8n and the URL from n8n is http://gotenberg:3000. Pin the version tag instead of latest, so a Chromium update never changes your invoices overnight.

Step 2: Build the HTML

Add a Code node that returns one item per document with the HTML in a field called html. My test built an A4 invoice from each row with a template string.

Start the CSS with @page { size: A4; margin: 0 } so the page size lives in the HTML.

Step 3: Turn the HTML into a file named index.html

Add a Convert to File node:

  • Operation: Convert to Text File
  • Text Input Field: html
  • Options, File Name: index.html

Gotenberg only converts a file called index.html. Many n8n community threads get stuck right here with a 400 error.

Step 4: POST the file to Gotenberg

Add an HTTP Request node:

  • Method POST to the route /forms/chromium/convert/html on http://gotenberg:3000
  • Body Content Type: Form-Data
  • An n8n Binary File parameter named files, Input Data Field Name data
  • Text parameters printBackground = true, paperWidth = 8.27, paperHeight = 11.7, and the four margin* fields = 0
  • Options, Response, Response Format: File

Each input item comes back as one PDF in the data binary field. Connect a Google Drive, S3 or Send Email node after it.

Things That Bit Me

  • Backgrounds vanish unless you send printBackground as true. The dark table header printed white without it.
  • The default paper is US Letter with about 1 cm margins. Send the A4 size and zero margins, or set them in @page.
  • Fonts fall back silently. My CSS asked for Inter, the container doesn't have it, and the PDF came out in Helvetica. Embed web fonts with @font-face or build an image with your fonts installed.
  • localhost from n8n. n8n tried the IPv6 address first and got "The service refused the connection". 127.0.0.1 or the Docker service name works.
Pros
  • Free and open source, no per-PDF cost
  • Runs on your own server, so documents stay in your network
  • Full CSS control, plus merge and Office to PDF routes
Cons
  • You maintain HTML, CSS and a Docker container
  • n8n Cloud can only reach it if you expose it to the internet
  • Fonts and page breaks are on you

Best for: developers who self-host n8n and already own the document as HTML.

2. Convert HTML to PDF with a Hosted API

A hosted HTML to PDF API takes the same HTML in one HTTP Request node, with no server to run. PDFShift is a typical one, so I use it as the example.

Pick this if you're on n8n Cloud, you have HTML, and you don't want to run Docker.

In the HTTP Request node:

  • POST https://api.pdfshift.io/v3/convert/pdf
  • Header X-API-Key with your key
  • JSON body { "source": {{ JSON.stringify($json.html) }} }
  • Options, Response Format: File

JSON.stringify matters. Without it, the first quote inside your HTML breaks the JSON body.

PDFShift charges per document, counted per 5 MB of output, with a small free tier (checked December 3, 2026).

To see how your HTML prints before wiring anything, paste it into our free HTML to PDF converter.

Pros
  • No server, works on n8n Cloud
  • Same HTML as Gotenberg, so you can switch later
Cons
  • Still HTML and CSS to maintain
  • Your documents leave your network
  • Per-document pricing on top of n8n

Best for: n8n Cloud users with existing HTML templates and modest volume.

3. Generate PDFs from a Template with the Orshot Node

Orshot is an API that turns your design templates into images, PDFs and videos. You design the PDF once in Orshot Studio, a visual editor. The Orshot node sends each row's values and gets a PDF link back.

Pick this if the PDF is designed (invoices, certificates, reports), someone who doesn't write HTML edits it, or you want the same template as a PNG later.

Step 1: Make your invoice template

Design your invoice in Studio, or bring the HTML invoice you already have with Import from HTML. Each dynamic layer has a Parameter ID, like total, in its API tab. That ID is the field name n8n fills.

Step 2: Add the Orshot node

Orshot is a verified node on n8n, so there's nothing to install. Search "Orshot" in the nodes panel and add it. For the credential, paste a key from API Keys in your Orshot dashboard.

Open the Orshot node on n8n100 free credits a month. No credit card required.

Step 3: Render each row as a PDF

  • Operation: Render a Studio Template
  • Template Name or ID: pick your template from the list
  • Response Format: PDF, Response Type: URL
  • Modifications: pick each field from the Key dropdown, which lists your template's fields, then drag the matching column from the input panel into Value
  • Optional, Options, Custom File Name: {{ $json.invoice_number }}

The PDF link comes out at {{ $json.data.data.content }}. Set Response Type to Binary when the next node needs the file itself, like a Google Drive upload.

Things That Bit Me

  • Fields you don't map keep the template's sample text. My first run printed 5 line items on a 2-item invoice and the sample "Amount due". Map every field you use, and send a single space for rows you don't use.
  • Page size follows the canvas. A 1000 px wide canvas gave a 750 pt page, not A4. Design at 794×1123 px for A4 and leave DPI unset; DPI scales the page, it doesn't sharpen it.

Multi-page documents come out of one call. Set a layer to Repeat on extra pages for headers and footers, and use {{_page_number}} and {{_total_pages}} in text for page numbers.

Every option in the node maps to a field in the PDF generation API.

Pros
  • No HTML: a designer edits the PDF in a visual editor
  • Verified node, works on n8n Cloud
  • The same template renders PNG, JPG or MP4 too
Cons
  • You design the template once before the first run
  • Costs credits: 1 per PDF page

Best for: teams that send designed PDFs on a schedule and don't want an HTML file in the loop.

Orshot solved every challenge with clarity and precision, and the entire PDF automation came together flawlessly.

I've never felt more confident in a technical build. Highly recommend Orshot.

David FurlongFounder, Return to Centre

4. Generate a PDF from a Google Doc in n8n

Google Docs gives you a free PDF path with only built-in n8n nodes. It fits letters, simple contracts and one-page summaries.

Pick this if the document is mostly text, your team already edits it in Google Docs, and you don't need tight layout control.

  1. Google Drive, Copy your template Doc for each row.
  2. Google Docs, Update the copy and replace {{client_name}} style placeholders with row values.
  3. Google Drive, Download the copy with Google File Conversion set to PDF.

Tables that grow with the data and exact positioning are hard here. Replace operations only swap text; they don't add rows.

Best for: Google Workspace teams with text-first documents and no budget for a PDF tool.

Orshot or Gotenberg? Same Invoice, Side by Side

Both workflows made a correct A4 invoice from the same row. The difference is what each one asks you to maintain, and how the PDF looks without extra work.

In my n8n test, Dec 2 2026Orshot nodeHTML + Gotenberg
Nodes in the workflow35
Code to maintainNoneAbout 25 lines of HTML and CSS
FontsThe template's own fontsInstalled in the container, or a fallback
Change the layoutEdit in Studio, n8n stays the sameEdit the Code node
Runs on n8n CloudYesOnly with a public Gotenberg server
Same design as a PNGChange Response FormatA separate Gotenberg route

Orshot rendered the designed template with its own fonts, which I never had to write, install or host. Gotenberg printed my hand-written HTML in Helvetica, because the container didn't have Inter.

Generate 1,000 PDFs in n8n without Timeouts

n8n runs a node once per incoming item, so 1,000 sheet rows feed 1,000 renders with no extra setup.

No Loop node needed. The Orshot node renders rows one after another, not all at once, and every Orshot plan allows at least 100 renders a minute. If a run ever hits the limit, the node stops with a clear "Too many requests" error; add a Wait node then.

Long documents. For multi-page reports, turn on Wait for Completion (Async) in the node's options. The node starts a background job and waits for it, so long renders don't time out.

For Gotenberg, the limit is your server. One container handled my 50 rows without a queue; for thousands at once, run two or three replicas behind a load balancer.

What Generating PDFs with Orshot Costs

Orshot charges 1 credit per PDF page, and every account gets 100 free credits a month, no card needed.

The Launch plan's 1,500 credits a month cover 1,500 one-page invoices for $39, checked on our pricing page on December 3, 2026.

The same credits render PNG, JPG and MP4 from your templates, so one plan covers the invoice PDF and its share image. Our PDF generation API comparison covers more tools.

Copy the n8n Workflows

Both workflows below are trimmed versions of the ones I ran. Copy one and paste it on the n8n canvas.

After pasting, pick your template in the Orshot node and connect your credential. Then check that each key matches a field in the Key dropdown.

{
  "name": "Invoice PDFs with Orshot",
  "nodes": [
    { "parameters": {}, "name": "Run manually", "type": "n8n-nodes-base.manualTrigger", "typeVersion": 1, "position": [0, 0] },
    {
      "parameters": {
        "jsCode": "return [\n  { json: { invoice_number: 'INV-2051', bill_to_name: 'Avery Coleman, Brightwave Media', item_1_desc: 'Brand identity system', item_1_amount: '$1,800.00', total: '$1,944.00' } },\n  { json: { invoice_number: 'INV-2052', bill_to_name: 'Jordan Patel, Harbor & Pine', item_1_desc: 'Social media template kit', item_1_amount: '$540.00', total: '$583.20' } }\n];"
      },
      "name": "Invoice rows", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [220, 0]
    },
    {
      "parameters": {
        "operation": "https://api.orshot.com/v1/studio/render",
        "studioTemplateId": "YOUR_TEMPLATE_ID",
        "responseFormat": "pdf",
        "responseType": "url",
        "options": { "customFileName": "={{ $json.invoice_number }}" },
        "studioModifications": {
          "modification": [
            { "key": "invoice_number", "value": "={{ $json.invoice_number }}" },
            { "key": "bill_to_name", "value": "={{ $json.bill_to_name }}" },
            { "key": "item_1_desc", "value": "={{ $json.item_1_desc }}" },
            { "key": "item_1_amount", "value": "={{ $json.item_1_amount }}" },
            { "key": "total", "value": "={{ $json.total }}" }
          ]
        }
      },
      "name": "Orshot", "type": "@thelifeofrishi/n8n-nodes-orshot.orshot", "typeVersion": 5, "position": [440, 0]
    }
  ],
  "connections": {
    "Run manually": { "main": [[{ "node": "Invoice rows", "type": "main", "index": 0 }]] },
    "Invoice rows": { "main": [[{ "node": "Orshot", "type": "main", "index": 0 }]] }
  }
}

Change the URL if Gotenberg isn't on the same Docker network as n8n.

{
  "name": "Invoice PDFs with Gotenberg",
  "nodes": [
    { "parameters": {}, "name": "Run manually", "type": "n8n-nodes-base.manualTrigger", "typeVersion": 1, "position": [0, 0] },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const r = { invoice_number: 'INV-2051', client: 'Brightwave Media', total: '$1,944.00' };\nconst html = `<!doctype html><html><head><meta charset=\"utf-8\"><style>@page { size: A4; margin: 0 } body { font-family: Helvetica, Arial, sans-serif; padding: 48px; border-top: 8px solid #2B42D4 } .total { background: #0f172a; color: #fff; padding: 16px; border-radius: 12px }</style></head><body><h1>Invoice ${r.invoice_number}</h1><p>Billed to ${r.client}</p><div class=\"total\">Total due ${r.total}</div></body></html>`;\nreturn { json: { invoice_number: r.invoice_number, html } };"
      },
      "name": "Build HTML", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [220, 0]
    },
    {
      "parameters": { "operation": "toText", "sourceProperty": "html", "options": { "fileName": "index.html" } },
      "name": "HTML to file", "type": "n8n-nodes-base.convertToFile", "typeVersion": 1.1, "position": [440, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://gotenberg:3000/forms/chromium/convert/html",
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            { "parameterType": "formBinaryData", "name": "files", "inputDataFieldName": "data" },
            { "name": "printBackground", "value": "true" },
            { "name": "paperWidth", "value": "8.27" },
            { "name": "paperHeight", "value": "11.7" },
            { "name": "marginTop", "value": "0" },
            { "name": "marginBottom", "value": "0" },
            { "name": "marginLeft", "value": "0" },
            { "name": "marginRight", "value": "0" }
          ]
        },
        "options": { "response": { "response": { "responseFormat": "file" } } }
      },
      "name": "Gotenberg", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [660, 0]
    }
  ],
  "connections": {
    "Run manually": { "main": [[{ "node": "Build HTML", "type": "main", "index": 0 }]] },
    "Build HTML": { "main": [[{ "node": "HTML to file", "type": "main", "index": 0 }]] },
    "HTML to file": { "main": [[{ "node": "Gotenberg", "type": "main", "index": 0 }]] }
  }
}

Rather not run n8n for this? Orshot's built-in workflows do the same loop, like the Google Sheets invoice generator and the certificate generator. Each row becomes a PDF.

Fix the Common n8n PDF Problems

Most failed n8n PDF runs come from five settings. Check these before anything else:

ProblemFix
Gotenberg returns 400Name the file index.html in Convert to File
Colors and backgrounds missingSend printBackground = true to Gotenberg
Wrong font in the PDFEmbed fonts with @font-face, or use a template with its fonts
A table row splits across pagesCSS tr { break-inside: avoid }; repeat headers with thead
Orshot PDF isn't A4Design the canvas at 794×1123 px and leave DPI unset

When HTML Is the Better Fit

Stick with HTML when a developer owns the document and edits it in code anyway. HTML also wins when invoices have line-item tables of any length, since CSS flows a long table across pages by itself.

Pick a template when the PDF is designed or a non-developer edits it. Generating social posts from n8n too? The n8n marketing automation tutorial uses the same Orshot node for images and videos.

Common Questions

Can n8n generate a PDF on its own?

Is there an HTML to PDF node in n8n?

How do I convert HTML to PDF in n8n for free?

How do I save a PDF from n8n to Google Drive?

How do I generate PDFs in bulk with n8n?

What is Orshot?

Sign up free, design your PDF in Studio and point the n8n node at it. You get 100 credits a month with no card needed.

If a PDF doesn't come out the way you expect, hit the chat button. I'm usually the one who answers.

Related posts