If your workflow generates invoices, reports, contracts, certificates, or any document that starts as HTML, you’ll eventually need to convert it into a PDF.
In this tutorial, I’ll show you how to generate PDFs directly inside n8n using PDF API Hub.
Video Tutorial: https://youtu.be/krTf17AeHOs?si=oPRPvCxVa4urtBB_
What You’ll Build
A simple n8n workflow that:
- Receives HTML content
- Sends it to PDF API Hub
- Generates a PDF
- Returns a downloadable PDF URL
Perfect for:
- Invoice generation
- Client reports
- Certificates
- Contracts
- Purchase orders
- Automated document workflows
Step 1: Create a New Workflow
Create a new workflow in n8n and add a Manual Trigger node.
This allows you to test the workflow quickly while building it.
Step 2: Add HTML Content
Add a Set node and create a field called:
{
"html": "<html><body><h1>Hello n8n!</h1><p>This PDF was generated automatically.</p></body></html>"
}
You can replace this with dynamic data later from Google Sheets, Airtable, Forms, CRM systems, or databases.
Step 3: Add the PDF API Hub Node
Install the PDF API Hub integration from the n8n community nodes and add it to your workflow.
Configure:
Operation: Generate PDF
Map the HTML field from the previous node.
The API supports:
- Raw HTML
- CSS styling
- Custom fonts
- A4, Letter, Legal paper sizes
- Landscape mode
- Background printing
- Dynamic placeholders
- URL to PDF conversion
Step 4: Configure PDF Settings
Example configuration:
- Paper Size: A4
- Print Background: True
- Margin: Medium
- Output Format: URL
These settings produce a downloadable PDF link that can be used in later workflow steps.
Step 5: Execute the Workflow
Run the workflow.
The node returns:
{
"success": true,
"pdf_url": "https://..."
}
You now have a PDF that can be:
- Emailed automatically
- Uploaded to Google Drive
- Saved to S3
- Attached to CRM records
- Sent through Slack or Teams
- Archived for compliance
Example Use Cases
Invoice Automation
Stripe → n8n → HTML Invoice → PDF → Email Customer
Weekly Reports
Database → HTML Report → PDF → Send to Management
Certificates
Form Submission → Generate Certificate HTML → PDF → Email User
Contracts
CRM Deal Won → Contract Template → PDF → Send for Signature
Why Use HTML Instead of PDF Templates?
HTML is easier to:
- Version control
- Generate dynamically
- Customize with CSS
- Reuse across workflows
- Preview in a browser before generating PDFs
This makes it ideal for automated document generation.
Watch the Full Tutorial
The complete walkthrough is available here:
If you’re building document automation workflows in n8n, this can save a significant amount of manual work and eliminate the need for custom PDF generation infrastructure.
Happy automating ![]()
Sample Templates: