n8n is a powerful workflow automation platform, but it doesn't have a native PDF generation node. The HTML to PDF API fills that gap: use the HTTP Request node to send HTML, receive PDF bytes, and pass them to any downstream node: email attachment, file storage, or webhook response.
HTTP Request Node Configuration
Add an HTTP Request node to your workflow with these settings:
{
"method": "POST",
"url": "https://platform.htmltopdfapi.co/api/v1/pdf/generate",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{ "name": "Authorization", "value": "Bearer YOUR_API_KEY" },
{ "name": "Content-Type", "value": "application/json" },
{ "name": "Accept", "value": "application/pdf" }
]
},
"sendBody": true,
"bodyParameters": {
"parameters": [
{ "name": "html", "value": "={{ $json.html }}" },
{ "name": "paper_size", "value": "a4" },
{ "name": "orientation", "value": "portrait" }
]
},
"responseFormat": "file"
}Build the HTML in a Code Node
const invoice = $input.first().json
const html = `
<!DOCTYPE html>
<html>
<body style="font-family:sans-serif;padding:32px">
<h1 style="color:#1e40af">Invoice #${invoice.number}</h1>
<p>Amount: <strong>$${(invoice.amount / 100).toFixed(2)}</strong></p>
<p>Customer: ${invoice.customer_name}</p>
<p>Date: ${new Date(invoice.created_at).toLocaleDateString()}</p>
</body>
</html>
`
return [{ json: { html } }]Example Automation
A typical invoice PDF workflow in n8n:
1. Stripe Trigger: fires on payment_intent.succeeded
2. HTTP Request: fetch invoice details from your backend
3. Code node: build the invoice HTML string
4. HTTP Request: POST to HTML to PDF API (responseFormat: file)
5. Gmail node: send email with the returned PDF as an attachment
Store your API key as an n8n credential (Header Auth) rather than hardcoding it in the node configuration.