Guide
HTML to PDF in n8n
n8n workflows can trigger PDF generation at any step: after a form submission, a database row insert, a webhook from your app, or a scheduled run. This guide shows how to wire an HTTP Request node to the PDF rendering endpoint so your workflow gets back either raw bytes or a hosted URL, ready to attach to an email or store in a bucket.
Overview
The PDF API accepts a POST to https://api.pdfpipe.xyz/v1/pdf with a JSON body containing your HTML and any render options. Authentication uses a bearer token passed in the Authorization header. In n8n, the cleanest way to manage that token is through a Header Auth credential so it never appears in the node parameters and is not visible in exported workflow JSON.
The response is either raw application/pdf bytes (the default) or a JSON object with a hosted url field when you pass "store": true in the body. The URL mode is often more practical inside workflows because it lets you pass a plain string to downstream nodes like Send Email or Slack.
Credential setup
In n8n, open Settings → Credentials → New credential and search for "Header Auth". Fill in the two fields:
- Name:
Authorization - Value:
Bearer pp_live_your_key_here
Save the credential with a recognizable name such as "PDFPipe API". Once saved, the token is encrypted at rest in n8n and you select it by name inside each HTTP Request node. Your API key never appears in the workflow JSON, which means you can export and share workflows safely.
Your API key is available on the dashboard after you sign up. Keys are prefixed with pp_live_.
Basic HTTP Request node config
Add an HTTP Request node to your workflow and configure it as follows:
- Method: POST
- URL:
https://api.pdfpipe.xyz/v1/pdf - Authentication: Predefined Credential Type → Header Auth → select "PDFPipe API"
- Body Content Type: JSON
- Response Format: File (to receive the PDF as a binary item)
Under "Body Parameters" switch to the JSON editor and paste the following. The double-brace expression pulls the html field from the previous node's output so you can build your HTML upstream and pass it through.
{
"html": "{{ $json.html }}",
"options": {
"format": "A4"
}
}With Response Format set to "File", n8n stores the PDF bytes as a binary attachment on the item, named data by default. You can rename it in the node settings or reference it as {{ $binary.data }} in downstream nodes. The Gmail and Outlook nodes both accept a binary attachment reference directly.
Full workflow JSON
Below is a minimal workflow export that strings together a Webhook trigger, the PDF render call (with store: true to get a URL back), and a placeholder email node. Import it via Workflows → Import from JSON and swap the credential name and email addresses to match your setup.
{
"name": "Generate PDF and email link",
"nodes": [
{
"parameters": {
"path": "generate-pdf",
"responseMode": "onReceived"
},
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [250, 300]
},
{
"parameters": {
"method": "POST",
"url": "https://api.pdfpipe.xyz/v1/pdf",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "httpHeaderAuth",
"sendBody": true,
"contentType": "json",
"jsonBody": "={\n \"html\": \"{{ $json.body.html }}\",\n \"store\": true,\n \"options\": { \"format\": \"A4\" }\n}",
"options": {}
},
"name": "Render PDF",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [470, 300],
"credentials": {
"httpHeaderAuth": {
"name": "PDFPipe API"
}
}
},
{
"parameters": {
"fromEmail": "[email protected]",
"toEmail": "={{ $('Webhook').item.json.body.email }}",
"subject": "Your PDF is ready",
"text": "Download your document here: {{ $json.url }}"
},
"name": "Send Email",
"type": "n8n-nodes-base.emailSend",
"typeVersion": 2,
"position": [690, 300]
}
],
"connections": {
"Webhook": {
"main": [[{ "node": "Render PDF", "type": "main", "index": 0 }]]
},
"Render PDF": {
"main": [[{ "node": "Send Email", "type": "main", "index": 0 }]]
}
}
}The Webhook node receives a JSON body with at least an html field and an email field. The Render PDF node calls the API and the response JSON lands on the item. The Send Email node then reads {{ $json.url }} from that response and puts it in the message body.
Using store: true for a hosted URL
When you add "store": true to the request body, the API renders the PDF, uploads it to storage, and returns a JSON response instead of raw bytes:
{
"url": "https://cdn.pdfpipe.xyz/docs/abc123.pdf",
"expires_at": "2026-07-13T00:00:00Z"
}This is the preferred mode for n8n workflows. The binary file approach works but means every downstream node that wants to email, upload, or log the PDF has to carry the binary data through the workflow. With a URL you pass a plain string: simpler expressions, cleaner logs, and no binary serialization overhead in the workflow execution history.
The URL is accessible for 30 days. If you need permanent storage, add a node after the Render PDF step that downloads the URL and uploads it to your own S3 bucket or file store before continuing.
{
"html": "{{ $json.html }}",
"store": true,
"options": {
"format": "A4",
"margin": { "top": "20mm", "bottom": "20mm" }
}
}Keeping the key out of workflow JSON
The Header Auth credential approach described in the setup section is the right way to handle the API key in n8n. A few things worth knowing:
- When you export a workflow, credentials are replaced with their name only. The actual token is never included in the export file, so sharing a workflow JSON with a colleague or committing it to a repository does not leak the key.
- On n8n Cloud, credentials are encrypted with a per-instance key. On self-hosted n8n, set a strong
N8N_ENCRYPTION_KEYenvironment variable before storing any credentials. The default key is not safe for production. - If you need different keys per environment (staging vs. production), create two credentials with different names ("PDFPipe API - Staging" and "PDFPipe API - Production") and switch the node's credential selection when promoting the workflow.
- Never paste the key directly into the node's "Headers" section as a raw value. That value is stored in the workflow JSON in plain text and will appear in exports.
Test your HTML in the live playground on the home page before embedding it in a workflow, then check the docs for the full list of render options including page size, margins, headers, footers, and landscape mode.
Get an API key →