Package Information
Released: 1/29/2025
Downloads: 29 weekly / 64 monthly
Latest Version: 1.0.10
Author: Bram Timmermans
Available Nodes
Documentation
PDF Merger Node for n8n
A custom node to merge two PDF files in your n8n workflows. Overlay the first page of a house-style PDF behind all pages of a content PDF, with fallback handling for missing or single-page PDFs.
📖 Overview
The PDF Merger Node allows you to:
- Overlay a "house style" PDF onto a "content" PDF by using only the first page of the house style as a background for all content pages.
- Always draw the content on top of the house style.
- Handle differences in page counts gracefully, defaulting to A4-size if no pages exist in either PDF.
- Output a single merged PDF file.
🛠️ Node Configuration
Inputs
- House Style PDF: Binary property for the house style file (default:
binaryData1). - Content PDF: Binary property for the content file (default:
binaryData2).
Additional Options
- Output File Name: Name used when storing the merged PDF (default:
merged.pdf). - Output Binary Property: Binary property name where the merged PDF is saved (default:
mergedPdf).
Output
- Merged PDF: The combined PDF file as a binary property in the item.
🚀 Installation
Step-by-Step Guide
- Clone the repository:
git clone https://github.com/silverkey-it/n8n-nodes-pdf-merger.git ``` - Navigate to the directory:
cd n8n-nodes-pdf-merger ``` - Install dependencies and build:
pnpm install && pnpm run build ``` - Copy the build to your n8n custom nodes folder:
cp -r dist/ ~/.n8n/custom/ ``` - Restart your n8n instance:
# If n8n is currently running, stop it first, then start. n8n stop && n8n start ``` or just start it if it was not running: ```bash n8n start ```
🏗️ Example Workflow
- Provide two PDFs to your workflow:
- One as house style (binary property
binaryData1). - One as content (binary property
binaryData2).
- One as house style (binary property
- Add the PDF Merger Node and configure the property names if needed.
- Execute the workflow, and the node will produce:
- A single merged PDF in the binary property you specify (default:
mergedPdf).
- A single merged PDF in the binary property you specify (default:
⚙️ How It Works Under the Hood
- Load PDFs: The node uses pdf-lib to load the house style and content PDFs.
- Embed Only the First Page of the House Style: Even if your house style has multiple pages, only page 1 is used as the background.
- Iterate Over Content Pages: For each content PDF page, the node:
- Creates a new page in the output PDF.
- Draws the background (house style) first.
- Draws the content page on top.
- Fallback Sizes: If a PDF has no pages, the node defaults to an A4-ish size (
595 × 842).
License
This project is licensed under the MIT License. Feel free to use, modify, and distribute as needed.
Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request.
Happy merging! 🎉