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. It is ready to run after you import it and add your keys.
Last updated
| Operations | render_html_to_pdf (POST /v1/render) |
|---|---|
| Platforms | n8n |
| Nodes | Webhook, Code, HTTP Request, 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 (HTTP Request). POSTs
{"html": ..., "filename": ...}tohttps://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. Every node ships with n8n, so the
workflow runs on n8n Cloud and self-hosted n8n with nothing to install.
Set up the HTTP Request node
Render PDF comes set up. Only the credential is yours to add:
- Method POST, URL
https://api.pdfrender.dev/v1/render. - Authentication: Generic Credential Type, Header Auth. Create a
credential with the name
X-API-Keyand your key as the value. - Send Body: JSON, with
htmlset to the Code node's output and afilename. - Options > Response > Response Format: File, Put Output in Field
data.
Get your API key. 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. The workflow uses only nodes that ship with n8n: Webhook, Code, HTTP Request and Gmail. The HTTP Request node POSTs html and filename as JSON to /v1/render and keeps the response as a file.