n8ntools-pdf-generator

N8N Tools - PDF Generator: Generate professional PDFs from templates with dynamic data injection

Package Information

Released: 8/19/2025
Downloads: 70 weeklyΒ /Β 2,440 monthly
Latest Version: 2.2.4
Author: paulobraga.bots

Documentation

N8N Tools - PDF Generator

npm version
npm downloads
License: MIT

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)

  1. Go to Settings > Community Nodes in your N8N interface
  2. Click Install a community node
  3. Enter n8n-nodes-n8ntools-pdf-generator
  4. Click Install

Via npm

npm install n8n-nodes-n8ntools-pdf-generator

Setup Credentials

  1. Sign up at N8N Tools and get your API key
  2. In N8N, create new N8N Tools API credentials
  3. Enter your API URL: https://api.n8ntools.io
  4. 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

  1. Go to N8N Tools and access your dashboard
  2. Navigate to PDF Templates
  3. Upload a DOCX file with placeholders like {{customer_name}}, {{amount}}
  4. 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

πŸ“‹ 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

πŸ“„ License

MIT License - see LICENSE file for details.


Part of the N8N Tools ecosystem β€’ Website β€’ All Packages

Discussion