Guide

Turn HTML into a PDF over a webhook in n8n

Order fieldValue
orderIdORD-10482
customer.namePriya Raman
layoutinvoice
items2 lines
One order posted to the webhook

PDFops renders the HTML

/api/html-to-pdf, once per order. Done by the n8n workflow below.

The sample PDF the HTML becomes: an invoice with a company heading, the customer, a table of line items, and subtotal, tax and total.
The PDF it becomes. Open the rendered PDF.

Teams that need a branded PDF out of structured data usually end up running a headless browser or a PDF library of their own. PDFops renders HTML to PDF over one API call, so an n8n workflow can build the HTML from the data and hand it over. This page offers one n8n workflow as a download, the order it expects, and what to know before you run it.

What you get

A webhook in n8n takes an order as JSON, checks every field, builds an invoice or packing-slip page in HTML, and PDFops renders it to a PDF. The PDF comes back in the response, or is stored in Google Drive and emailed with the link in the reply. See a rendered sample PDF.

Set it up

  1. Check your n8n has the node version it needs. The workflow uses the HTML to PDF operation, which is in n8n-nodes-pdfops 0.5.0 and newer. On a self-hosted n8n, install or update the community node from npm. n8n Cloud installs version 0.4.0 today, which does not have the operation, so the workflow imports on Cloud but its render nodes have no HTML to PDF to run.
  2. Get a free key and add the credentials. Create a free API key and paste it into a PDFops credential. The workflow also needs a Header Auth credential for the webhook and a Slack credential for alerts. Add a Google Drive and a Gmail credential too if you will use delivery link.
  3. Edit Set Document Options. In the Set Document Options node, set the company name, the accent colour, the page size (letter or a4) and the Slack channel for alerts. To change the layout, replace the HTML in the two builder nodes.
  4. Test with Order Webhook inactive. Import the workflow and keep it inactive. In the editor, open Order Webhook, choose Listen for test event, and POST the order below to its Test URL with your Header Auth value. Use delivery download, so the PDF is the response and nothing is stored or emailed. Keep a valid customer.email in the order even so: the workflow checks it on every order, and a missing or invalid one gets a 400 before anything is rendered. Open the PDF and check the layout and the totals.
  5. Activate and post to the Production URL. When the PDF is right, activate the workflow and post orders to the Production URL of Order Webhook. With delivery link, which is the default, the PDF is stored in Google Drive, emailed with Gmail, and the reply carries the Drive link.
  6. Know what a render costs. A successful HTML render counts 5 requests against your PDFops quota, because rendering costs more than a plain PDF operation. Orders that fail the check never reach PDFops and count nothing.

The order the webhook takes

The order arrives as JSON, the workflow builds the HTML from it, and the HTML goes in one POST call to /api/html-to-pdf (endpoint reference) with page_size: "letter", margin: 36, print_background: true. The workflow checks the order first (lengths, ranges, up to 200 line items, a real issue date, one email address) and answers 400 with the list of issues before anything is rendered. The layout field picks invoice or packing-slip. Amounts are worked out in the currency's own decimals and rounded half up. customer.email is required on every order, delivery download included: without one valid address the reply is a 400 and nothing is rendered. This is the order behind the sample PDF.

{
  "orderId": "ORD-10482",
  "customer": {
    "name": "Priya Raman",
    "email": "priya@example.com",
    "address": "12 Harbour Lane, Leeds"
  },
  "currency": "EUR",
  "taxRate": 19,
  "layout": "invoice",
  "delivery": "download",
  "notes": "Net 30.",
  "items": [
    {
      "description": "Hydraulic seal kit (M12)",
      "quantity": 3,
      "unitPrice": 22
    },
    {
      "description": "On-site fitting, per hour",
      "quantity": 2.5,
      "unitPrice": 65
    }
  ]
}

Workflow

n8n

Download the n8n workflow JSON: Generate invoice or packing slip PDFs from JSON orders with HTML to PDF. It is not in n8n's template gallery, so import the file into your own n8n. It uses the n8n-nodes-pdfops community node.

Steps: Webhook (Order Webhook receives the order as JSON), then Code (Validate Order Payload, answering 400 with the issues), then Switch (Choose an invoice or a packing-slip layout), then Code (Build the HTML with escaped values), then PDFops (Render HTML to PDF, retried once when the renderer is busy), then Google Drive (Store the PDF, when delivery is link), then Gmail (Email the PDF, when delivery is link), then Slack (Alert on any other failure).

Before you run it. Order Webhook starts the workflow the moment it is active and the URL is called, so keep the workflow inactive until you have run it by hand. The nodes need n8n-nodes-pdfops 0.5.0 or newer: n8n Cloud installs 0.4.0 today, which has no HTML to PDF operation, so on Cloud the two render nodes would have to be replaced by HTTP Request nodes calling the endpoint. Slack is used on every failure path, including delivery download, so add a Slack credential even if you only download; without it the alert fails and the caller gets a 502 that says alerting also failed. Every order needs a valid customer.email, delivery download included; without one the webhook answers 400. Delivery link also stores the file in Google Drive and emails it with Gmail. Posting the same orderId twice renders twice, and with delivery link stores a second file and sends a second email.

Can run without a paid plan. n8n has no free Cloud plan (n8n.io/pricing, read 2026-11-27). The workflow runs without a licence fee on self-hosted Community Edition with n8n-nodes-pdfops 0.5.0 or newer and a free PDFops key. n8n Cloud installs community node 0.4.0 today (api.n8n.io/api/community-nodes, read 2026-11-28), which has no HTML to PDF operation.

Get a free PDFops key for n8n

Frequently asked

Is this workflow in the n8n template gallery?

No. It is a downloadable workflow file on this page, so there is no gallery page for it. Download the JSON and import it into your own n8n.

Does it run on n8n Cloud?

Not as shipped. It needs n8n-nodes-pdfops 0.5.0 or newer for the HTML to PDF operation, and n8n Cloud installs 0.4.0 today. On Cloud you would replace the two render nodes with HTTP Request nodes that call the endpoint with your API key. On a self-hosted n8n you install the newer node from npm.

Does it run on a free plan?

n8n has no free Cloud plan. A self-hosted n8n has no licence fee, and a free PDFops key covers the renders within its monthly quota, at 5 requests per render. Slack is needed on every failure path, and Google Drive and Gmail for delivery link.

Why does a download test get a 400?

The most likely cause is the customer email. Validate Order Payload requires one valid customer.email on every order, delivery download included, even though download sends no email. It also bounds the other fields and lists up to 10 issues in the 400 reply.

Can I send my own HTML instead of an order?

Yes. The endpoint takes any HTML string up to 1 MB, as a full page or a fragment. This workflow builds the HTML from an order; replace the two builder nodes to render something else. JavaScript does not run, so a page that builds itself in the browser renders empty.

Can the HTML load images and fonts?

Images, stylesheets and fonts load over https from public hosts, and data: URIs work. Addresses on private networks and plain http are blocked and skipped. The endpoint reference lists the exact limits.

What happens when the renderer is busy or fails?

When the renderer answers renderer_busy, the workflow waits and retries once. A timeout or an exhausted quota is not retried. Any other failure alerts Slack and answers 502 without upstream error text. If Drive stored the file but Gmail failed, the reply says so and still carries the link.

What if my caller retries a request?

A retry is not deduplicated. Posting the same orderId again renders again, and with delivery link it stores a second file and sends a second email.

Try it

Get a free API key, then open a workflow above. The endpoint reference lists every option and limit.