n8n4 min read · June 15, 2026

Generate PDF Documents in n8n Workflows

n8n has no built-in PDF node. Here's how to generate PDFs in n8n using the HTTP Request node, with a working JSON configuration and real automation examples.

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:

HTTP Request node settingsjson
{
  "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

Code node: build invoice HTMLjs
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.