PdfKit

PDFKit Node

Overview

This node converts one or more images from the input item's binary data into a single PDF file. It is useful in workflows where you need to aggregate multiple images (such as scanned documents, photos, or screenshots) into a single PDF for sharing, archiving, or further processing. For example, you could use this node to combine uploaded receipts into a single expense report PDF.

Properties

Display Name Type Description
Destination Key String The name of the binary key where the resulting PDF will be stored.
PDF Name String The filename for the output PDF (without extension).
Keep Images Boolean Whether to retain the original image binaries after conversion.

Output

  • The node outputs items with a binary property containing the generated PDF under the key specified by Destination Key.
  • The PDF file will have the name provided in PDF Name, with a .pdf extension.
  • If Keep Images is set to false, the original image binaries used for the PDF are removed from the output item; otherwise, they are retained.
  • The json field of the output remains unchanged from the input unless an error occurs.

Example Output Structure

{
  "json": { /* original JSON data */ },
  "binary": {
    "myPdfKey": {
      "data": "<Buffer ...>", // PDF file content
      "fileName": "output.pdf",
      "mimeType": "application/pdf"
    }
    // (other binaries if 'Keep Images' is true)
  }
}

Dependencies

  • External Libraries:
    • pdfkit: Used to generate PDF files.
    • image-size: Used to determine image dimensions.
  • n8n Requirements:
    • No special environment variables or API keys required.

Troubleshooting

  • "No binary data exists on item!"
    This error occurs if the input item does not contain any binary data. Ensure that your workflow provides image files as binary data to this node.
  • PDF Not Generated / Empty Output:
    Make sure the input contains at least one binary property with an image file type.
  • File Overwrite:
    If the Destination Key matches an existing binary key, the PDF will overwrite it.
  • Image Format Issues:
    Only binary properties with fileType set to "image" are processed. Non-image binaries are ignored.

Links and References

Discussion