Back to Blog
n8nPDFautomationtutorialdocuments

Automate PDF Generation with n8n: Invoices, Reports & Documents

n8nautomation TeamApril 10, 2026
TL;DR: n8n can generate, parse, merge, and manipulate PDFs using community nodes like pdforge and PDF.co, or via HTTP Request nodes hitting any PDF API. This guide walks through building real workflows for automated invoices, reports, and document processing pipelines.

Automating PDF generation with n8n eliminates the tedious manual work of creating invoices, reports, contracts, and other documents your business produces repeatedly. Whether you need to generate hundreds of personalized invoices after each billing cycle or compile weekly analytics into a polished PDF report, n8n workflows handle it without writing backend code or managing PDF libraries yourself.

The n8n ecosystem now includes dedicated community nodes for PDF creation and manipulation, plus you can connect to any PDF API through the HTTP Request node. This gives you full flexibility to build document automation pipelines that fit your exact stack.

Why Automate PDF Generation with n8n

Most businesses generate PDFs manually — exporting from spreadsheets, copy-pasting into templates, or using clunky desktop software. This creates bottlenecks:

  • Invoices go out late because someone has to manually create each one
  • Reports are inconsistent because different team members format them differently
  • Document processing requires someone to open, read, and re-enter data from incoming PDFs
  • Scaling means hiring more people to do repetitive document work

n8n solves this by letting you build visual workflows that trigger PDF generation automatically — from a new order in Shopify, a completed form in Typeform, a row added to Google Sheets, or on a time-based schedule. The generated PDFs can be emailed, uploaded to cloud storage, or passed to the next step in your workflow.

PDF Nodes and Tools Available in n8n

You have several options for working with PDFs in n8n, depending on your needs:

pdforge (Community Node) — A dedicated node for generating PDFs from HTML templates. You design your template with HTML/CSS, inject dynamic data from your workflow, and get a polished PDF back. Ideal for invoices, receipts, and branded documents.

PDF.co (Community Node) — A more comprehensive tool that handles generation, parsing, splitting, merging, OCR, form filling, and conversion. It connects to the PDF.co API and covers nearly every PDF operation you might need.

HTTP Request Node + Any PDF API — You can connect to services like Gotenberg (self-hosted HTML-to-PDF), DocRaptor, PDFShift, or any REST API that generates PDFs. This approach gives you maximum flexibility and works without installing community nodes.

Code Node + Binary Data — For simple cases, you can use the Code node with libraries to generate basic PDFs programmatically, then pass the binary output downstream.

Tip: If you're running n8n on n8nautomation.cloud, you can install community nodes like pdforge and PDF.co directly from the node settings panel — no command-line access needed.

Workflow 1: Auto-Generate Invoices from CRM Data

This workflow triggers whenever a deal closes in your CRM and generates a branded PDF invoice automatically.

Trigger: Webhook node (receives payload when deal status changes to "won") or a CRM trigger node (HubSpot, Pipedrive, etc.)

Step 1 — Fetch customer data: Use your CRM node to pull the customer's billing details — name, address, tax ID, and line items from the deal.

Step 2 — Build the HTML template: Use a Set node or Code node to construct your invoice HTML. Inject the customer name, line items, totals, and invoice number into a pre-designed template string.

// Example template variables in Code node
const invoiceHTML = `
<div style="font-family: Arial; padding: 40px;">
  <h1>Invoice #${items[0].json.invoiceNumber}</h1>
  <p>Bill to: ${items[0].json.customerName}</p>
  <table>
    ${items[0].json.lineItems.map(item =>
      `<tr><td>${item.description}</td><td>$${item.amount}</td></tr>`
    ).join('')}
  </table>
  <p><strong>Total: $${items[0].json.total}</strong></p>
</div>`;
return [{ json: { html: invoiceHTML } }];

Step 3 — Generate PDF: Pass the HTML to the pdforge node (or an HTTP Request to Gotenberg/DocRaptor). The node returns binary PDF data.

Step 4 — Deliver: Use the Gmail or SMTP node to email the PDF as an attachment, and optionally upload it to Google Drive or S3 for archival.

Workflow 2: Scheduled Weekly PDF Reports

This workflow runs every Monday morning, pulls metrics from multiple sources, and compiles them into a single PDF report sent to stakeholders.

Trigger: Schedule Trigger node — set to fire every Monday at 8:00 AM.

Step 1 — Gather data: Use parallel branches to pull data from multiple sources simultaneously:

  • Google Analytics node → website traffic metrics
  • Stripe node → revenue and subscription numbers
  • PostgreSQL node → custom business KPIs
  • HubSpot node → new leads and pipeline value

Step 2 — Merge and format: Use a Merge node to combine all data streams, then a Code node to calculate week-over-week changes and format everything into an HTML report with charts (you can embed chart images from QuickChart.io or similar services via URL).

Step 3 — Convert to PDF: Send the compiled HTML through your PDF generation node. For reports with charts, pdforge handles embedded images well.

Step 4 — Distribute: Email the PDF to your distribution list using the Gmail node, and post a notification to Slack with the report attached.

Tip: Use the QuickChart.io API in an HTTP Request node to generate chart images dynamically. Pass your data as URL parameters and embed the returned image URL in your HTML template before PDF conversion.

Workflow 3: Parse PDFs and Extract Structured Data

Not all PDF automation is about generation — extracting data from incoming PDFs is equally valuable. This workflow processes incoming invoices or documents and pulls structured data into your systems.

Trigger: Gmail Trigger node (watches for emails with PDF attachments) or a Webhook that receives uploaded files.

Step 1 — Extract the attachment: The Gmail node outputs binary data for attachments. Use an IF node to filter for PDF files only.

Step 2 — Parse the PDF: Send the binary data to PDF.co's "PDF to Text" or "PDF to JSON" action. For structured documents like invoices, use the "Document Parser" action with a pre-configured template that maps specific regions of the PDF to fields.

Step 3 — Process with AI (optional): For unstructured PDFs, pass the extracted text to an AI node (OpenAI, Anthropic) with a prompt like: "Extract the vendor name, invoice number, date, line items, and total from this invoice text. Return as JSON."

Step 4 — Route the data: Use a Switch node to route based on document type or vendor, then write the extracted data to your accounting software, Google Sheets, or database via the appropriate node.

Workflow 4: Merge and Watermark Documents

This workflow combines multiple PDFs into a single document and applies a watermark — useful for assembling contract packages, proposal decks, or compliance documentation.

Trigger: Webhook node (called from your app when a document package is requested).

Step 1 — Fetch source documents: Use Google Drive, S3, or HTTP Request nodes to download the individual PDFs that need merging — cover page, terms and conditions, pricing sheet, appendices.

Step 2 — Merge PDFs: Use PDF.co's "Merge PDFs" action, passing all binary files as input. The node combines them in the order specified.

Step 3 — Add watermark: If the document is a draft or confidential, use PDF.co's watermark action to stamp "DRAFT" or "CONFIDENTIAL" across each page.

Step 4 — Deliver: Upload the final merged PDF to your storage and return the download URL via the Respond to Webhook node so your application can serve it to the user.

Best Practices for PDF Automation in n8n

Template management: Store your HTML templates in a dedicated location — a Google Drive document, a database field, or even a GitHub repo. Pull the template at runtime rather than hardcoding it in the Code node. This lets non-developers update the design without touching the workflow.

Handle binary data carefully: PDFs are binary data in n8n. When passing them between nodes, make sure you're referencing the correct binary property name (usually "data" or "attachment_0"). Use the "Move Binary Data" node if you need to convert between binary and base64.

Error handling for external APIs: PDF generation APIs can timeout on large documents. Add error handling with retry logic — use an IF node to check the HTTP status code, and loop back with a Wait node if you get a 429 or 503 response.

File naming conventions: Use dynamic file names that include dates and identifiers — like invoice-{{customerName}}-{{date}}.pdf. This makes documents searchable in storage and prevents overwrites.

Testing with sample data: Build your workflow with a Manual Trigger first, using hardcoded sample data. Once the PDF output looks correct, swap in the real trigger and dynamic data sources.

Note: Community nodes like pdforge and PDF.co require API keys from their respective services. Some offer free tiers (PDF.co gives 100 credits/month). Factor API costs into your workflow planning for high-volume document generation.

Performance at scale: If you're generating hundreds of PDFs in a batch (like monthly invoices for all customers), use the SplitInBatches node to process them in groups of 10-20. This prevents timeout errors and keeps your n8n instance responsive. Running on n8nautomation.cloud gives you dedicated resources so batch jobs don't compete with your other workflows for memory and CPU.

PDF automation is one of those workflows that pays for itself almost immediately — the time saved on even a single weekly report or invoice run adds up fast. With n8n's visual builder, you can have a working PDF pipeline in under an hour, and iterate on templates without redeploying anything.

Ready to automate with n8n?

Get affordable managed n8n hosting with 24/7 support.