Webhook JSON to PDF, sent by email (n8n)
An n8n workflow that turns nested JSON from a webhook into a formatted PDF and emails it. Import it, add your keys, done.
Last updated
| Operations | render_html_to_pdf (POST /v1/render) |
|---|---|
| Platforms | n8n |
| Nodes | Webhook, Code, pdfrender, Gmail |
A system posts JSON to a webhook, often nested: a customer with an address, a list of line items. This workflow turns that payload into a clean PDF and emails it to the address in the payload. A Code node builds the HTML, pdfrender renders it, and Gmail sends the PDF as an attachment.
The Code node reads only the fields you name, so fields the payload adds later cannot break the layout. Every value is HTML-escaped before it reaches the page. The sample builds an order confirmation with a line-item table, a total and page numbers.
The steps
- Receive order JSON (Webhook, POST). It answers the caller at once; the PDF is made afterwards.
- Build HTML (Code). Picks the fields, escapes them and writes an A4
HTML page with a
@pagefooter for page numbers. - Render PDF (pdfrender, Render HTML to PDF). Sends the HTML to
POST https://api.pdfrender.dev/v1/renderand puts the PDF in the binary fielddata. - Email the PDF (Gmail). Attaches
dataand sends it tocustomer.email.
The Webhook node carries pinned sample data, so Execute workflow runs the whole chain before a real call arrives. Inline images and fonts as data: URIs, because remote URLs are rejected (how).
Get the workflow
Download workflow.json and its setup notes from
GitHub,
then use Import from File in n8n. On self-hosted n8n, install the
community node @pdfrender-dev/n8n-nodes-pdfrender under Settings >
Community Nodes first.
Get your API key
Get your API key and add it to n8n as a pdfrender API credential. Each render costs 1 credit, whatever its page count, and a failed render costs nothing.
FAQ
- What happens when the JSON payload gains a new field?
- Nothing breaks. The Code node reads only the fields it names and ignores the rest, so a new or renamed key cannot change the layout. To show a new field, add it to the Code node.
- Does this work on n8n Cloud?
- Yes, with one swap. n8n Cloud installs only verified community nodes, and the pdfrender node is not verified yet. Replace it with an HTTP Request node that POSTs html and filename as JSON to /v1/render. Send your key in the X-API-Key header and set the response format to File. The template's README has the exact settings.