Convert HTML to PDF using n8n action
PDF4me Convert HTML to PDF transforms HTML content into high-quality PDF documents through n8n automation workflows. Process HTML files via n8n triggers, binary data, base64 strings, or public URLs to generate PDFs with preserved CSS styles, embedded images, fonts, responsive layouts, and dynamic content rendering. This solution is ideal for web page archiving, automated report generation, email-to-PDF conversion, invoice creation, documentation systems, and content publishing workflows that require accurate HTML rendering with professional PDF output and seamless integration.
Setup
Add the PDF4me "Convert HTML to PDF" node to your n8n workflow and configure the required parameters. For initial setup instructions, see our n8n Integration Guide.
Prerequisites:
- PDF4me API credentials
- n8n workflow access
Configuration:
- Add PDF4me node to workflow
- Select "Convert HTML to PDF" action
- Configure input parameters (see below)

Parameters
Complete list of parameters for the Convert HTML to PDF action. Configure these parameters to control HTML to PDF conversion.
Important: Parameters marked with an asterisk (***) are required and must be provided for the action to function correctly.
| Parameter | Type | Description | Example |
|---|---|---|---|
| Input Data Type*** | String | HTML Input Format Selection • Choose the format of your HTML data input • PDF4me supports multiple input types for flexibility • Options: Binary Data, Base64 String, HTML Code, or URL | Binary Data |
| Input Binary Field | Binary | Binary HTML File Input (Required if Binary Data) • Reference HTML file from previous n8n node or file upload • PDF4me processes binary HTML files with automatic format detection • Required when Input Data Type is "Binary Data" | {{ $binary.data }} |
| Base64 HTML Content | String | Base64 Encoded HTML Input (Required if Base64 String) • Provide HTML content as base64 encoded string • PDF4me automatically decodes and processes the HTML content • Required when Input Data Type is "Base64 String" | PGh0bWw+ |
| HTML Code | String | Raw HTML Code Input (Required if HTML Code) • Write raw HTML code manually • Will be automatically converted to base64 format • Required when Input Data Type is "HTML Code" | <html>Hello</html> |
| HTML URL | String | Public HTML URL Input (Required if URL) • Provide a public/open permission URL to the HTML file • PDF4me downloads and processes the file from URL • Required when Input Data Type is "URL" | https://abc.com/page.html |
| HTML File Name*** | String | HTML Input Filename • Specify the name of the input HTML file • Must include proper extension (.html, .htm) • PDF4me uses this for format detection and processing | document.html |
| Index File Path*** | String | Index File Reference • Specify the path to the main HTML file (index.html) • For HTML projects with multiple files • PDF4me uses this as entry point for rendering | index.html |
| Output File Name*** | String | PDF Output Filename • Specify the name for the generated PDF file • Must include .pdf extension • PDF4me ensures unique naming and format validation | output.pdf |
| Binary Data Output Name*** | String | Binary Data Output Mapping • Define the variable name for accessing generated PDF binary data • Used in subsequent workflow actions • Essential for workflow automation | data |
Advanced Options
The following parameters are available in the Advanced Options section and are optional:
| Parameter | Type | Description | Example |
|---|---|---|---|
| Layout | String | Page Orientation Setting • Choose between Portrait (vertical) or Landscape (horizontal) • Affects PDF page dimensions and content flow • Default is Portrait | Portrait |
| Format | String | Page Size Format • Select the paper size format for PDF generation • Supports standard formats: A-series, Legal, Tabloid • Default is A4 | A4 |
| Scale | Decimal | Content Scaling Factor • Control the size of content in the PDF • 1.0 represents 100% original size • Maintains quality while adjusting dimensions | 0.8 |
| Top Margin | String | Top Margin Configuration • Set the top margin space (pixels, inches, or centimeters) • Ensures consistent spacing from top edge • Default is 40px | 40px |
| Bottom Margin | String | Bottom Margin Configuration • Configure bottom spacing for proper page layout • Prevents content from being cut off • Default is 40px | 40px |
| Left Margin | String | Left Margin Configuration • Define the left margin space for content positioning • Maintains consistent left alignment • Default is 40px | 40px |
| Right Margin | String | Right Margin Configuration • Set the right margin to control content width • Prevents text cutoff • Default is 40px | 40px |
| Print Background | Boolean | Background Printing Control • Enable or disable background elements (colors, patterns, images) • Ensures accurate visual representation • Default is false | false |
| Display Header Footer | Boolean | Header/Footer Visibility • Control inclusion of page headers and footers • Includes page numbers, titles, timestamps • Default is false | false |
Output
Output Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| fileName | String | PDF4me generated PDF filename - The complete filename of the successfully generated PDF document with proper .pdf extension. PDF4me ensures unique naming and validates file format compliance for seamless integration with downstream processes | output.pdf |
| mimeType | String | PDF4me MIME type identifier - The standardized MIME type for the generated PDF file, always set to application/pdf by PDF4me's conversion engine. This ensures proper file handling and recognition across all systems and applications | application/pdf |
| fileSize | Number | PDF4me PDF file size in bytes - The exact size of the generated PDF file in bytes, provided by PDF4me for storage planning, bandwidth optimization, and file transfer monitoring. Essential for enterprise document management and workflow automation | 30063 |
| success | Boolean | PDF4me conversion status indicator - Boolean flag indicating the success or failure of the HTML-to-PDF conversion process. PDF4me returns true for successful conversions and false for any errors, enabling robust error handling in automated workflows | true |
| message | String | PDF4me conversion status message - Descriptive message indicating the result of the HTML-to-PDF conversion process. PDF4me provides clear status messages for successful conversions and detailed error information for troubleshooting purposes | HTML converted to PDF successfully |
N8N Action Response
The PDF4me Convert HTML to PDF API returns a response that can be viewed in multiple formats. Choose the view that best fits your needs:
- JSON
- Table
- Schema
- Binary
JSON Response Format
The raw JSON response from the API:
{
"fileName": "output.pdf",
"mimeType": "application/pdf",
"fileSize": 30063,
"success": true,
"message": "HTML converted to PDF successfully"
}
Table View
Response data in a structured table format:
| Parameter | Value |
|---|---|
| fileName | output.pdf |
| mimeType | application/pdf |
| fileSize | 30063 |
| success | true |
| message | HTML converted to PDF successfully |
Schema View
The data structure and types of the response:
fileName: AB output.pdf
mimeType: AB application/pdf
fileSize: # 30063
success: ☑ true
message: AB HTML converted to PDF successfully
Type Indicators:
AB= String#= Number☑= Boolean
Binary Data View
The actual PDF file data and metadata:
data
─────────────────────────────
File Name: output.pdf
File Extension: pdf
Mime Type: application/pdf
File Size: 1.35 MB
Binary Data Access:
- n8n Binary Object:
$binary.data.data - Base64 Content: Available for direct use
- File Operations: Ready for download, email, or storage
Use Cases
Web Content Archiving and Documentation
- Convert dynamic web pages, online articles, and digital content into PDF format for long-term archiving, compliance documentation, and legal record keeping
- Process web-based reports, dashboards, and analytics pages by converting them to PDF format for offline access, sharing, and presentation purposes
- Archive website snapshots and online documentation by converting HTML content to PDF format for historical preservation and reference purposes
Email Marketing and Digital Communications
- Convert HTML email templates and newsletters to PDF format for print distribution, offline sharing, and compliance with email marketing regulations
- Process web-based forms and surveys by converting HTML submissions to PDF format for record keeping, analysis, and regulatory compliance
- Generate PDF versions of web-based catalogs, brochures, and promotional materials for offline distribution and print marketing campaigns
Web Application and System Integration
- Convert web-based reports and data visualizations to PDF format for automated report generation, system integration, and business intelligence workflows
- Process web-based invoices, receipts, and financial documents by converting HTML content to PDF format for accounting systems and financial record keeping
- Generate PDF versions of web-based contracts, agreements, and legal documents for digital signatures, archiving, and legal compliance