PdfKit

PDFKit Node

Overview

This node provides PDF manipulation capabilities with two main operations: converting images to a PDF and merging two existing PDFs into one. It is useful in workflows where you need to generate PDFs from image files or combine multiple PDF documents into a single file.

Common scenarios:

  • Creating a PDF report or album from a set of images.
  • Combining multiple PDF documents (e.g., contracts, invoices) into a single consolidated PDF for easier sharing or archiving.

Practical example:

  • You receive several scanned images of receipts and want to create a single PDF file containing all these images.
  • You have two separate PDF files representing different sections of a report and want to merge them into one comprehensive document.

Properties

Name Meaning
Operation The action to perform: "Convert Images To PDF" or "Merge PDFs".
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 file.
Keep Images (Only for "Convert Images To PDF") Whether to keep the original images in the binary data after conversion.
First PDF Binary Field (Only for "Merge PDFs") The binary field name containing the first PDF to merge.
Second PDF Binary Field (Only for "Merge PDFs") The binary field name containing the second PDF to merge.
Keep Source PDFs (Only for "Merge PDFs") Whether to keep the source PDFs in the binary data after merging.

Output

The node outputs items with updated binary data containing the generated or merged PDF under the specified destination key. The binary data includes:

  • A PDF file named as per the "PDF Name" property with .pdf extension.
  • For "Convert Images To PDF", the PDF contains pages created from each image found in the input binary data.
  • For "Merge PDFs", the PDF contains all pages from both source PDFs concatenated in order.

If configured to keep source files (images or PDFs), those remain in the binary data; otherwise, they are removed to save space.

No additional JSON fields are added or modified beyond error handling in failure cases.

Dependencies

  • Uses the pdfkit library to create PDFs from images.
  • Uses the pdf-lib library to load and merge existing PDF files.
  • Uses the image-size library to determine dimensions of images for proper page sizing.
  • Requires access to binary data buffers of input items.
  • No external API keys or services are required.

Troubleshooting

  • Error: "No binary data exists on item!"
    Occurs if the input item does not contain any binary data. Ensure that the previous node provides binary files.

  • Error: "First PDF field 'X' does not exist on item!" or "Second PDF field 'Y' does not exist on item!"
    Happens when the specified binary field names for the PDFs to merge do not match any binary keys in the input item. Verify the exact binary field names.

  • Error merging PDFs: ...
    Indicates an issue loading or processing the PDF files, possibly due to corrupted or invalid PDF content. Check the source PDF files for integrity.

  • Images not appearing in PDF or PDF empty
    Make sure the input binary data contains valid image files and that the "Keep Images" option is set according to your needs.

  • Output PDF filename missing or incorrect
    Confirm that the "PDF Name" property is set and includes a valid filename without extension (the node appends .pdf automatically).

Links and References

Discussion