Overview
This node provides PDF manipulation capabilities with three main operations: converting images to a PDF, merging two PDFs into one, and converting an Excel sheet to a PDF. It is useful in workflows where you need to generate or combine PDF documents dynamically from various input formats.
- Convert Images To PDF: Takes multiple image files from binary data and compiles them into a single PDF document.
- Merge PDFs: Combines two existing PDF files (from binary data) into one consolidated PDF.
- Convert Excel To PDF: Converts a specified worksheet from an Excel file into a formatted PDF document.
Practical examples:
- Creating a PDF portfolio from multiple images uploaded by users.
- Merging contract pages stored as separate PDFs into a single document for easier distribution.
- Generating printable reports from Excel spreadsheets automatically.
Properties
| Name | Meaning |
|---|---|
| Destination Key | The name of the binary key where the resulting PDF will be stored. |
| PDF Name | The filename to assign to the output PDF document. |
| First PDF Binary Field | The binary field containing the first PDF file to merge (used only in Merge PDFs operation). |
| Second PDF Binary Field | The binary field containing the second PDF file to merge (used only in Merge PDFs operation). |
| Keep Source PDFs | Whether to retain the original source PDFs in the binary data after merging (boolean). |
Output
The node outputs items with a binary property containing the generated PDF under the specified destination key. The PDF is stored as binary data with the given filename and MIME type application/pdf.
- For imagesToPDF and mergePDFs, the output binary contains the merged or created PDF.
- For xlsxToPDF, the output binary contains the PDF rendering of the selected Excel worksheet.
- If configured, the original source files (images, PDFs, or Excel files) can be optionally kept in the binary data.
Dependencies
- Uses the
pdf-liblibrary to manipulate and merge PDF documents. - Uses
pdfkitto create PDFs from images and Excel data. - Uses
image-sizeto determine dimensions of images. - Uses
exceljsto read Excel files and extract worksheet data. - Requires input items to have binary data fields containing images, PDFs, or Excel files depending on the operation.
No external API keys or services are required; all processing is done locally within the node.
Troubleshooting
- Missing Binary Data: Errors occur if expected binary fields (e.g., PDFs or Excel files) are not present on the input item. Verify that the binary field names exactly match those configured.
- Invalid PDF Files: When merging PDFs, corrupted or invalid PDF files may cause errors. Ensure input PDFs are valid and not damaged.
- Worksheet Not Found: For Excel to PDF conversion, specifying a non-existent sheet name or invalid index will throw an error. Check available worksheet names and indexes.
- Empty Worksheet: Converting an empty worksheet results in an error. Confirm the worksheet contains data.
- Output Key Conflicts: If the destination key conflicts with existing binary keys and "keep source" options are false, source data will be removed. Be cautious to avoid unintended data loss.
Links and References
- pdf-lib GitHub - PDF manipulation library used for merging PDFs.
- pdfkit Documentation - Library used for creating PDFs from images and Excel data.
- exceljs GitHub - Library for reading Excel files.
- image-size npm - Used to get image dimensions.