Skip to main content

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:

  1. Add PDF4me node to workflow
  2. Select "Convert HTML to PDF" action
  3. Configure input parameters (see below)
Convert HTML to PDF

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.

ParameterTypeDescriptionExample
Input Data Type***StringHTML 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 FieldBinaryBinary 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 ContentStringBase64 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 CodeStringRaw 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 URLStringPublic 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***StringHTML 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***StringIndex 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***StringPDF 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***StringBinary 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:

ParameterTypeDescriptionExample
LayoutStringPage Orientation Setting
• Choose between Portrait (vertical) or Landscape (horizontal)
• Affects PDF page dimensions and content flow
• Default is Portrait
Portrait
FormatStringPage Size Format
• Select the paper size format for PDF generation
• Supports standard formats: A-series, Legal, Tabloid
• Default is A4
A4
ScaleDecimalContent Scaling Factor
• Control the size of content in the PDF
• 1.0 represents 100% original size
• Maintains quality while adjusting dimensions
0.8
Top MarginStringTop Margin Configuration
• Set the top margin space (pixels, inches, or centimeters)
• Ensures consistent spacing from top edge
• Default is 40px
40px
Bottom MarginStringBottom Margin Configuration
• Configure bottom spacing for proper page layout
• Prevents content from being cut off
• Default is 40px
40px
Left MarginStringLeft Margin Configuration
• Define the left margin space for content positioning
• Maintains consistent left alignment
• Default is 40px
40px
Right MarginStringRight Margin Configuration
• Set the right margin to control content width
• Prevents text cutoff
• Default is 40px
40px
Print BackgroundBooleanBackground Printing Control
• Enable or disable background elements (colors, patterns, images)
• Ensures accurate visual representation
• Default is false
false
Display Header FooterBooleanHeader/Footer Visibility
• Control inclusion of page headers and footers
• Includes page numbers, titles, timestamps
• Default is false
false

Output

Output Parameters

ParameterTypeDescriptionExample
fileNameStringPDF4me 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 processesoutput.pdf
mimeTypeStringPDF4me 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 applicationsapplication/pdf
fileSizeNumberPDF4me 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 automation30063
successBooleanPDF4me 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 workflowstrue
messageStringPDF4me 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 purposesHTML 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 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"
}

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

Get Help