n8n-nodes-html2pdf
v0.1.2
Published
Convert HTML content or URLs to PDF with exact visual rendering
Downloads
52
Maintainers
Readme
n8n-nodes-html-to-pdf
Convert HTML content or URLs to PDF files with exact visual rendering in n8n.
Features
- ✅ Convert HTML to PDF - Direct HTML content conversion
- ✅ Convert URLs to PDF - Capture any webpage as PDF
- ✅ Exact Visual Rendering - Preserves structure, styling, fonts, colors, images
- ✅ Multiple Page Formats - A4, Letter, Legal, A3
- ✅ Flexible Orientation - Portrait or landscape
- ✅ Configurable Margins - Custom margins with units (px, mm, cm, in)
- ✅ CSS Support - Print backgrounds, colors, and images
- ✅ Scale Control - Adjust rendering size (0.1x to 2.0x)
- 🎯 Perfect for: Emails, invoices, reports, archiving, documentation
Installation
Via n8n UI (Recommended)
- Go to Settings > Community Nodes
- Click Install
- Enter:
n8n-nodes-html-to-pdf - Click Install
- Restart n8n (required for nodes to load)
Via npm
cd ~/.n8n
npm install n8n-nodes-html-to-pdf
# Then restart n8nUsage
Convert HTML Content to PDF
- Add "HTML to PDF" node to your workflow
- Select Source Type: "HTML Content"
- Paste your HTML in the HTML Content field
- Configure PDF options (format, orientation, etc.)
- Execute workflow
- Download PDF from output
Convert URL to PDF
- Add "HTML to PDF" node to your workflow
- Select Source Type: "URL"
- Enter the webpage URL
- Configure PDF options
- Execute workflow
- Download PDF from output
Configuration Options
| Option | Description | Default | |--------|-------------|---------| | Source Type | "HTML Content" or "URL" | HTML Content | | HTML Content | HTML code to convert | - | | URL | Webpage URL to convert | - | | PDF File Name | Output filename | document.pdf | | Page Format | A4, Letter, Legal, A3 | A4 | | Orientation | Portrait (false) or Landscape (true) | Portrait | | Print Background | Include CSS backgrounds/colors/images | ✅ Enabled | | Scale | Rendering scale (0.1-2.0) | 1.0 | | Margins | Top, Right, Bottom, Left (with units) | 0 |
Examples
Example 1: Convert HTML Email to PDF
<html>
<body style="font-family: Arial; padding: 20px;">
<h1 style="color: #2c3e50;">Invoice #12345</h1>
<p>Date: 2025-01-15</p>
<table style="width: 100%; border-collapse: collapse;">
<tr style="background: #3498db; color: white;">
<th>Item</th><th>Quantity</th><th>Price</th>
</tr>
<tr>
<td>Product A</td><td>2</td><td>$50</td>
</tr>
</table>
</body>
</html>Result: Professional PDF invoice with exact styling preserved
Example 2: Webpage to PDF
Source Type: URL
URL: https://example.com/article
Format: A4
Orientation: Portrait
Print Background: ✅
Result: Complete PDF of webpage with all styles and imagesExample 3: In n8n Workflow
[HTTP Request] → [HTML to PDF] → [Email] / [Google Drive] / [Dropbox]
↓ ↓ ↓
Get HTML Convert to PDF Send/SaveTechnical Details
- Rendering Engine: Chromium (via html-pdf-node/Puppeteer)
- Output Format: Binary PDF compatible with n8n
- Package Size: ~300 MB (includes Chromium)
- Processing: Server-side, private, no external API calls
Requirements
- n8n: Version 0.220.0 or higher
- Node.js: Version 20.15 or higher
- Environment: Self-hosted n8n only (not n8n Cloud)
Use Cases
- 📧 Email Archiving - Convert HTML emails to PDF
- 🧾 Invoice Generation - HTML templates → PDF invoices
- 📄 Report Creation - Web data → PDF reports
- 📊 Dashboard Snapshots - Save dashboards as PDF
- 📋 Web Archiving - Archive webpages as PDF documents
- 🎨 Marketing Materials - Convert designs to PDF
Troubleshooting
Node Not Appearing
- Restart n8n completely (critical step)
- Clear browser cache
- Verify package name:
n8n-nodes-html-to-pdf - Check n8n logs for errors
PDF Output Issues
Blank PDF:
- Enable Print Background option
- Verify HTML content is valid
- For URLs, check webpage is publicly accessible
Missing Fonts:
- Use web-safe fonts (Arial, Times, etc.)
- Include font files in HTML
- Or use web fonts (Google Fonts)
Missing Images:
- Use absolute URLs (not relative)
- Or encode as base64 data URIs
- Ensure images are publicly accessible
Installation Issues
Module not found after install:
- Solution: Restart n8n (nodes load at startup)
Permission errors:
- Use
sudo npm installif needed - Or fix npm permissions
Development
Built using the n8n Custom Node Template
To build from source:
git clone https://github.com/yourusername/n8n-nodes-html-to-pdf.git
cd n8n-nodes-html-to-pdf
npm install
npm run build
npm linkThen link in n8n:
cd ~/.n8n/custom
npm link n8n-nodes-html-to-pdfSupport
- Issues: GitHub Issues
- Community: n8n Community Forum
- Discussions: GitHub Discussions
License
MIT
Changelog
0.1.0 (2025-01-15)
- Initial release
- HTML to PDF conversion
- URL to PDF conversion
- Configurable page formats (A4, Letter, Legal, A3)
- Portrait/landscape orientation
- Custom margins
- CSS background rendering
- Scale control
- Chromium-based rendering for exact visual fidelity
