node-red-contrib-pdf-merge
v1.2.3
Published
A Node-RED node to merge multiple PDFs into a single PDF
Downloads
23
Maintainers
Readme
Node-RED PDF Merge Node
Description
This Node-RED node allows you to merge multiple PDF files into a single PDF. It uses the pdf-lib
library for processing and merging the PDFs. The node is compatible with both x86 and ARM-based systems.
Features
PDF Merging: Combines multiple PDF files into a single file.
Relative and Absolute Paths: Supports both relative paths based on the Node-RED data directory and absolute paths.
Flexible Storage Location: Allows specifying where the merged PDF should be saved, either through configuration or dynamically in the flow.
Installation
To install this node, use the Node-RED Palette Manager or install it directly via npm:
npm install node-red-contrib-pdf-merger
Usage
The inputs can be made directly in the node or transferred as a payload.
It is important that the payload is transferred in the correct format. See the Flow Example below.
Configuration
Node Properties
Name (optional): A custom name for the node.
PDF List (Paths): A list of paths to the PDF files to be merged. Paths can be relative to the Node-RED data directory or absolute.
Output Filename (optional): The name of the output PDF file. Defaults to merged.pdf.
Output Path (optional): A relative or absolute path where the merged PDF should be saved. If not specified, the PDF will be saved in the Node-RED data directory.
Configuration Example
{
"name": "My PDF Merger",
"pdfList": "/data/PDFs/Dashboard.pdf,/data/PDFs/Dashboard2.pdf",
"outputFilename": "merged_output.pdf",
"outputPath": "/data/MergedPDFs"
}
Flow Example
Here is an example with transfer in the payload:
[
{
"id": "ab089b1a54159fe9",
"type": "pdf-merge",
"z": "5e8e11b7e36a10d3",
"name": "My PDF Merger",
"pdfList": "",
"outputFilename": "",
"outputPath": "",
"x": 1100,
"y": 880,
"wires": [
[
"1eda07b4df1d8e50"
]
]
},
{
"id": "6fc65def4a16bf92",
"type": "inject",
"z": "5e8e11b7e36a10d3",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 780,
"y": 880,
"wires": [
[
"2c7065b5cf7197d0"
]
]
},
{
"id": "2c7065b5cf7197d0",
"type": "function",
"z": "5e8e11b7e36a10d3",
"name": "function 35",
"func": "msg.payload = {};\nmsg.payload.pdfPaths = [\n \"/PDFs/Dashboard.pdf\",\n \"/PDFs/Dashboard2.pdf\"\n]\nmsg.payload.outputPath = \"/data/MergedPDFs\";\nmsg.payload.outputFilename = \"merged_output.pdf\";\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 930,
"y": 880,
"wires": [
[
"ab089b1a54159fe9"
]
]
},
{
"id": "1eda07b4df1d8e50",
"type": "debug",
"z": "5e8e11b7e36a10d3",
"name": "debug 202",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "counter",
"x": 1235,
"y": 880,
"wires": [],
"l": false
}
]
Here is an example with the node configuration only:
[
{
"id": "e5bce75f.60a5b8",
"type": "pdf-merge",
"z": "9c9b7c18.5498b8",
"name": "Merge PDFs",
"pdfList": "/PDFs/Dashboard.pdf, /PDFs/Dashboard2.pdf",
"outputFilename": "merged_output.pdf",
"outputPath": "/data/MergedPDFs",
"x": 480,
"y": 160,
"wires": [
[
"9a1c9b6f.9d9c6"
]
]
},
{
"id": "9a1c9b6f.9d9c6",
"type": "debug",
"z": "9c9b7c18.5498b8",
"name": "Debug Output",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 640,
"y": 160,
"wires": []
}
]
Usage
Add the pdf-merge node to your flow.
Configure the paths to the PDF files you want to merge.
Set the name and storage location for the output PDF file.
Connect the node to other nodes in the flow and deploy your changes.
The node will merge the specified PDF files and save the resulting PDF at the specified location.
Troubleshooting
File Operation Errors: Ensure that the paths provided are correct and that Node-RED has the necessary permissions to read and write the files.
Performance Issues: Check your system's resources, especially if processing large PDFs or merging many PDFs.
License
This node is licensed under the MIT License.