PDF Convert icon

PDF Convert

Convert PDF files to images using pdf2pic

Overview

This node converts PDF files from binary input into images, supporting PNG and JPEG formats. It is useful when you need to extract visual content from PDFs for further processing, previewing, or integration with image-based workflows. For example, it can convert multi-page PDFs into separate image files for each page, enabling thumbnail generation, OCR preprocessing, or embedding pages as images in reports.

Properties

Name Meaning
Binary Property Name of the binary property that contains the PDF file to be converted.
Output Format The image format for output pages: either PNG or JPEG.
Density (DPI) Image resolution in dots per inch; higher values produce better quality but larger files.
Output Property Name of the JSON property where the converted images and metadata will be stored.

Output

The node outputs an array of items, each containing:

  • json:
    • Original input JSON merged with a new property (named by Output Property) holding:
      • totalPages: Number of pages converted.
      • format: The chosen image format (png or jpeg).
      • density: The DPI used for conversion.
      • pdfSize: Size in bytes of the original PDF binary data.
  • binary:
    • Contains one binary entry per PDF page named as {Output Property}_page_{pageNumber}.
    • Each binary entry includes:
      • Base64-encoded image data of the page.
      • MIME type (image/png or image/jpeg).
      • Filename like page_{pageNumber}.{extension}.
      • File extension matching the output format.

This structure allows downstream nodes to access individual page images easily.

Dependencies

  • Requires the external Node.js package pdf2pic for PDF-to-image conversion.
  • Relies on system-installed GraphicsMagick or ImageMagick for rendering PDF pages.
  • Uses Node.js core modules fs, path, and os for temporary file handling.
  • No internal credential or API key is needed.

Troubleshooting

  • Common issues:

    • Missing GraphicsMagick or ImageMagick installation will cause conversion failure.
    • Incorrect binary property name leads to "no binary data found" errors.
    • Insufficient permissions to write/read temporary files may cause failures.
  • Error messages:

    • "PDF conversion failed: ... Make sure GraphicsMagick or ImageMagick is installed in your system."
      • Solution: Install GraphicsMagick or ImageMagick on the host machine.
    • Errors about missing binary data:
      • Verify the binary property name matches the actual input binary field.
    • File system errors during temp file creation or deletion:
      • Check folder permissions and available disk space.
  • The node supports "continue on fail" mode to skip problematic items without stopping the entire workflow.

Links and References

Discussion