Package Information
Documentation
N8N Tools - PDF Generator
Generate professional PDFs from HTML content, DOCX templates, or web pages. This N8N community node integrates with the N8N Tools platform to provide comprehensive PDF generation capabilities.
β¨ Features
- π Generate from HTML: Convert HTML content directly to PDF with full CSS support
- π Generate from Templates: Use predefined DOCX templates with dynamic data injection
- π Generate from URL: Convert any webpage to PDF with customizable options
- π¨ Customizable Options: Paper format (A4, A3, Letter, Legal), orientation, margins
- π Headers & Footers: Optional header and footer inclusion
- πΎ File Output: Returns PDF as binary data for further processing
- π° Cost Tracking: Built-in usage monitoring and budget controls
- π Secure: API key authentication with your N8N Tools account
π Quick Start
Installation
Install this node in your N8N instance:
Via Community Nodes (Recommended)
- Go to Settings > Community Nodes in your N8N interface
- Click Install a community node
- Enter
n8n-nodes-n8ntools-pdf-generator - Click Install
Via npm
npm install n8n-nodes-n8ntools-pdf-generator
Setup Credentials
- Sign up at N8N Tools and get your API key
- In N8N, create new N8N Tools API credentials
- Enter your API URL:
https://api.n8ntools.io - Enter your API key
π Usage
Supported Operations
| Operation | Description | Endpoint | Status |
|---|---|---|---|
| Generate from HTML | Convert HTML content to PDF | /api/v1/pdf/generate |
β Available |
| Generate from Template | Generate PDF using DOCX templates | /api/v1/pdf/generate/docx |
β Available |
| Generate from URL | Convert web pages to PDF | /api/v1/pdf/generate |
β Available |
Example Workflows
HTML to PDF
[Manual Trigger] β [Function Node] β [N8N Tools PDF Generator] β [Save to Drive]
Template-based Invoice
[Database] β [Process Data] β [N8N Tools PDF Generator] β [Email PDF]
URL to PDF Report
[Schedule Trigger] β [N8N Tools PDF Generator] β [Archive PDF]
βοΈ Configuration Examples
1. Generate from HTML Content
{
"operation": "generateFromHtml",
"htmlContent": "<html><head><style>body{font-family:Arial;}.header{color:#2563eb;}</style></head><body><div class='header'>RelatΓ³rio de Vendas</div><p>Vendas do mΓͺs: R$ 15.000,00</p></body></html>",
"options": {
"filename": "relatorio-vendas.pdf",
"format": "A4",
"orientation": "portrait",
"marginTop": "2cm",
"marginBottom": "2cm"
}
}
2. Generate from DOCX Template
{
"operation": "generateFromTemplate",
"templateId": "invoice_template_123",
"templateData": {
"customer_name": "JoΓ£o Silva",
"invoice_number": "INV-2024-001",
"amount": 1500.00,
"date": "15/01/2024",
"items": [
{
"description": "Desenvolvimento Web",
"quantity": 40,
"unit_price": 75.00,
"total": 3000.00
}
]
},
"options": {
"filename": "fatura-joao-silva.pdf",
"format": "A4"
}
}
3. Generate from URL
{
"operation": "generateFromUrl",
"url": "https://example.com/report",
"options": {
"filename": "website-report.pdf",
"format": "A4",
"orientation": "portrait",
"printBackground": true,
"waitDelay": 5000,
"emulatedMediaType": "screen"
}
}
π§ Node Parameters
Operation Selection
- Generate from HTML: Convert HTML string to PDF
- Generate from Template: Use DOCX template with data injection
- Generate from URL: Convert webpage to PDF
Input Parameters
HTML Content (for HTML operation)
- HTML Content: Raw HTML string with optional CSS styling
- Supports full HTML5 and CSS3 features
- External resources (images, fonts) must be accessible
Template Configuration (for Template operation)
- Template: Select from available DOCX templates or enter template ID
- Template Data: JSON object with data to populate template placeholders
URL Configuration (for URL operation)
- URL: Target webpage URL to convert
- Print Background: Include background graphics (default: true)
- Wait Delay: Time to wait before capture in milliseconds (default: 3000)
- Emulated Media Type: Screen or Print media (default: screen)
Output Options
- Filename: Name for the generated PDF file (default: "document.pdf")
- Format: Paper format - A4, A3, Letter, Legal (default: A4)
- Orientation: Portrait or Landscape (default: Portrait)
- Margins: Top, bottom, left, right margins (default: 1cm each)
- Headers/Footers: Optional header and footer inclusion
π€ Output Data
The node returns:
{
"success": true,
"filename": "relatorio-vendas.pdf",
"size": 245760,
"operation": "generateFromHtml",
"creditsUsed": 1,
"creditsRemaining": 99,
"costUSD": "0.02"
}
Binary Data: The generated PDF is available as binary data in the data property.
π¨ HTML Generation Tips
Best Practices
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
@page {
size: A4;
margin: 2cm;
}
body {
font-family: 'Arial', sans-serif;
font-size: 14px;
line-height: 1.6;
}
.header {
background-color: #2563eb;
color: white;
padding: 20px;
text-align: center;
margin-bottom: 30px;
}
.content {
padding: 20px;
}
.footer {
position: fixed;
bottom: 0;
width: 100%;
text-align: center;
font-size: 12px;
color: #666;
}
</style>
</head>
<body>
<div class="header">
<h1>RelatΓ³rio Mensal</h1>
</div>
<div class="content">
<h2>Dados de Performance</h2>
<p>Vendas realizadas: R$ 15.000,00</p>
</div>
<div class="footer">
Gerado em {{ date }} - PΓ‘gina 1
</div>
</body>
</html>
Supported CSS Features
- Layout: Flexbox, Grid, Positioning
- Typography: Web fonts (Google Fonts), font styling
- Colors: All CSS color formats
- Images: Base64 embedded or external URLs
- Print-specific:
@page,@media print
π§ Template System
Creating DOCX Templates
- Go to N8N Tools and access your dashboard
- Navigate to PDF Templates
- Upload a DOCX file with placeholders like
{{customer_name}},{{amount}} - Save and copy the template ID
Template Placeholder Syntax
Simple values: {{customer_name}}
Number formatting: {{amount}}
Date formatting: {{date}}
Conditional sections: Basic conditional rendering
List iteration: {{#items}}...{{/items}} for repeating sections
π URL Generation Features
Supported Websites
- Static websites: HTML, CSS, JavaScript
- Dynamic content: Single Page Applications (SPAs)
- Authentication: Public pages only
- Responsive design: Mobile and desktop layouts
Advanced URL Options
- Wait Delay: Allow time for JavaScript execution
- Print Background: Include background images and colors
- Media Type: Screen vs Print CSS styles
- Custom margins: Override default page margins
Common Use Cases
// Dashboard reports
{
"url": "https://analytics.company.com/dashboard",
"waitDelay": 10000,
"emulatedMediaType": "screen"
}
// News articles
{
"url": "https://news.example.com/article/123",
"printBackground": false,
"emulatedMediaType": "print"
}
// Product pages
{
"url": "https://store.com/product/laptop",
"waitDelay": 5000,
"printBackground": true
}
πΈ Pricing & Limits
- HTML Generation: 1 credit per document
- Template Generation: 1 credit per document
- URL Generation: 2 credits per document
- File Size Limit: 50MB per PDF
- Processing Time: Usually under 15 seconds
- Page Limit: Up to 100 pages per document
- API Rate Limit: Based on your N8N Tools subscription
π οΈ Advanced Usage
Error Handling
Enable "Continue on Fail" to handle errors gracefully:
{
"error": "Failed to generate PDF from URL: timeout",
"success": false
}
Workflow Context
The node automatically includes workflow context for tracking:
- Workflow ID
- Node name
- Execution ID
Budget Alerts
Monitor usage with automatic budget alerts:
{
"budgetAlert": "warning",
"budgetMessage": "80% of monthly budget used"
}
π¨ Common Issues & Solutions
HTML Generation Issues
{
"error": "Invalid HTML content",
"solution": "Validate HTML syntax and ensure proper DOCTYPE"
}
Template Issues
{
"error": "Template not found: invalid_template_id",
"solution": "Verify template ID exists in your N8N Tools account"
}
URL Generation Issues
{
"error": "URL timeout or inaccessible",
"solution": "Check URL accessibility and increase waitDelay if needed"
}
Performance Optimization
- Large HTML: Break into smaller documents
- Complex URLs: Increase wait delay for JavaScript-heavy sites
- Template data: Optimize JSON structure for faster processing
π Related Packages
- Web Scraper: Extract data for PDF generation
- Document Processor: Process and convert documents
π Requirements
- N8N version 0.174.0 or higher
- N8N Tools account and API key
- For templates: DOCX templates uploaded to N8N Tools platform
- Node.js 18+ (for development)
π Support
- π§ Email: support@n8ntools.io
- π Documentation: docs.n8ntools.io
- π¬ Community: Discord
- π Issues: GitHub
π License
MIT License - see LICENSE file for details.
Part of the N8N Tools ecosystem β’ Website β’ All Packages