PDF Page Extract icon

PDF Page Extract

Extract pages from PDF as images with configurable options

PDF Page Extract

AI-generated

Overview

This node extracts pages from a PDF file and converts them into images with configurable options. It supports extracting all pages, the first page, the last page, a specific page, or a range of pages. The PDF data can be sourced from binary data, a base64 string, or a file path. The output images can be customized in terms of quality, format (PNG or JPEG), maximum dimensions, and file naming pattern. This node is useful for workflows that require processing or analyzing PDF content as images, such as document previews, image-based data extraction, or visual content manipulation.

Use Case Examples

  1. Extract the first page of a PDF received as binary data from a previous node and output it as a medium-quality PNG image.
  2. Extract a range of pages from a PDF file located on the file system, convert them to JPEG images with high quality, and save them with a custom file name pattern.
  3. Convert a base64-encoded PDF string from input data into individual PNG images for each page, resizing them to fit within specified maximum dimensions.

Properties

Name Meaning
PDF Data Source Specifies where to get the PDF data from, options include binary data from a previous node, base64 string from input, or file path.
Binary Field Name Name of the binary field containing the PDF data (used when data source is binary).
Base64 Field Name Name of the field containing base64 encoded PDF data (used when data source is base64).
File Path Field Name Name of the field containing the file path to the PDF (used when data source is file path).
Page Selection Which page(s) to extract from the PDF, such as all pages, first page, last page, a range, or a specific page.
Page Number Specific page number to extract (1-based, used when page selection is specific).
Start Page First page of range to extract (1-based, used when page selection is range).
End Page Last page of range to extract (1-based, used when page selection is range).
Image Quality/Scale Quality/scale of the extracted images, affecting image resolution and file size.
Output Format Output image format, either PNG (lossless) or JPEG (compressed).
Max Width (Pixels) Maximum width of output images in pixels.
Max Height (Pixels) Maximum height of output images in pixels.
Output File Name Pattern Pattern for output file names, supporting placeholders for page number and file extension.
Output Binary Field Name Name for the output binary field to store the extracted image data.

Output

JSON

  • message - Status message indicating successful extraction of a PDF page.
  • pageNumber - The page number extracted from the PDF.
  • totalPages - Total number of pages in the PDF document.
  • width - Width of the extracted image in pixels.
  • height - Height of the extracted image in pixels.
  • scale - Scale factor used for the image extraction.
  • format - Image format of the extracted page (png or jpeg).
  • imageSize - Size of the extracted image data in bytes.
  • outputBinaryField - Name of the binary field containing the image data.
  • processedAt - Timestamp when the page was processed.

Dependencies

  • pdfjs-dist library for PDF processing
  • Node.js 'fs' module for file system access

Troubleshooting

  • Ensure the specified binary field contains valid PDF data when using binary data source.
  • Verify the base64 string is correctly formatted and contains PDF data when using base64 data source.
  • Check that the file path exists and points to a valid PDF file when using file path data source.
  • Page numbers must be within the valid range of the PDF document; invalid page numbers are skipped.
  • Errors during PDF loading or rendering will throw node operation errors with descriptive messages.

Links

Discussion