n8n-nodes-html-pdf-ariutomo
v1.0.6
Published
n8n custom node to convert HTML strings into PDF binary files using Puppeteer
Downloads
432
Readme
n8n-nodes-html-pdf
This is a custom n8n community node that allows you to easily convert HTML strings into PDF binary files using Puppeteer. It provides extensive customization options, including format sizing, page margins, orientation, header/footer templates, scaling, and custom output binary property names.
Features
- HTML to PDF Conversion: Input direct HTML strings and render them into high-fidelity PDF documents.
- Customizable Output Field: Change the output binary field name (defaults to
data). - Standard Sizing & Orientation: Select standard page formats (A0-A6, Letter, Legal, Tabloid, Ledger) or specify custom width/height dimensions.
- Landscape Toggling: Switch between Portrait and Landscape modes.
- Background Graphics: Choose whether to print background colors and images.
- Margins Control: Define Top, Bottom, Left, and Right margins.
- Header & Footer Templates: Inject custom HTML templates for page headers and footers with helper classes like
pageNumber,totalPages,date,title, andurl. - Scaling & Transparency: Scale page rendering and choose to omit white background for transparent PDFs.
Installation
For n8n Community Nodes (Recommended)
You can install this node via the Community Nodes panel in your n8n settings:
- Open your n8n instance.
- Go to Settings > Community Nodes.
- Click Install a community node.
- Enter the npm package name:
n8n-nodes-html-pdf - Accept the risk and click Install.
For Local Development / Self-Hosted n8n (Manual)
To install the node locally in your self-hosted n8n environment:
- Navigate to your n8n custom node installation directory (usually
~/.n8n/nodes/or/home/node/.n8n/custom/node_modules/in Docker environments). - Install the package:
npm install n8n-nodes-html-pdf - Restart your n8n instance.
Configuration Options
1. HTML Input (Required)
The HTML content you want to convert into a PDF. You can pass raw HTML or drag in values/variables from previous nodes using n8n expressions.
2. Output Binary Field Name (Required)
The name of the binary property where the generated PDF file buffer will be stored. Defaults to data.
3. PDF Options (Optional)
Click Add Option to configure advanced print settings:
- Format: The paper size (e.g.
A4,Letter,Legal,Custom). - Width / Height: Set dimensions manually when using
Customformat (e.g.,800px,10in,21cm). - Landscape: Toggles landscape print orientation.
- Print Background: Set to
trueto include background graphics and CSS background colors. - Display Header/Footer: Displays the header and footer templates on every page.
- Header / Footer Template: Custom HTML string templates. Use classes
.pageNumber,.totalPages,.date,.title, or.urlto inject dynamic values. - Margins: Top, Bottom, Left, Right margins (e.g.,
10px,0.5in,1cm). - Scale: Scale factor of the webpage rendering (must be between
0.1and2). - Omit Background: Generates a PDF with transparent backgrounds instead of white.
- Page Ranges: Subset of pages to print (e.g.
'1-5, 8, 11-13'). - Prefer CSS Page Size: Uses size dimensions declared in CSS
@pageover layout properties.
Local Development & Testing
1. Clone & Install Dependencies
git clone https://github.com/ariutomo/n8n-nodes-html-pdf.git
cd n8n-nodes-html-pdf
npm install2. Build the Node
Compile the TypeScript code:
npm run build3. Link for Local Testing
Link this package locally to your n8n instance to test:
npm linkThen inside your local n8n installation directory:
npm link n8n-nodes-html-pdfAnd start n8n.
