Overview
This node converts PDF files into images, supporting multiple pages and customizable output formats. It is useful when you need to extract visual content from PDFs for further processing, display, or archival in image form. For example, converting a multi-page PDF report into individual PNG or JPEG images for use in web galleries, thumbnails, or document previews.
The node reads a PDF file from a specified binary property, converts either all pages or a selected page range into images, and outputs each page as a separate item with the image stored in a binary property.
Properties
| Name | Meaning |
|---|---|
| PDF Binary Property | Name of the binary property that contains the input PDF file. |
| Output Format | Image format for output pages: PNG or JPEG. |
| Quality | JPEG quality level (1-100). Only applicable if output format is JPEG. |
| DPI | Output image resolution in dots per inch (72-600). |
| Width | Output image width in pixels. Leave empty for automatic sizing. |
| Height | Output image height in pixels. Leave empty for automatic sizing. |
| Convert All Pages | Whether to convert all pages (true) or only a specified page range (false). |
| Page Range | If not converting all pages, specify pages to convert (e.g., "1-5" or "1,3,5"). |
| Output Binary Property Name | Name of the binary property where converted images will be stored. |
Output
The node outputs one item per converted page. Each item contains:
json:- Original input JSON data merged with:
pageNumber: The current page number.totalPages: Total number of pages converted.fileName: The generated image file name (e.g., "page_1.png").
- Original input JSON data merged with:
binary:- A binary property (name configurable) containing the image data encoded in base64.
- Metadata includes MIME type (
image/pngorimage/jpeg), file name, and extension.
No other output fields are produced. The node does not output any non-image binary data.
Dependencies
- Uses the
pdf2piclibrary to perform PDF-to-image conversion. - Requires access to the local filesystem's temporary directory to store intermediate files during conversion.
- No external API keys or online services are needed.
- Node environment must allow file system operations and have sufficient permissions.
Troubleshooting
- Invalid page range errors: If the page range string is malformed (e.g., "5-1" or non-numeric values), the node throws an error. Ensure page ranges are valid and properly formatted.
- Missing or incorrect binary property: If the specified PDF binary property does not exist or is empty, the node will fail. Verify the input binary property name matches the actual input data.
- File system permission issues: The node writes temporary files to the OS temp directory. Lack of write permissions or disk space can cause failures.
- Unsupported PDF format or corrupted files: The underlying library may fail on certain PDFs; ensure input PDFs are valid.
- Large PDFs or many pages: Converting large documents or many pages may consume significant memory and time. Consider limiting page ranges or increasing system resources.
- JPEG quality out of range: Quality must be between 1 and 100; values outside this range are rejected.
Links and References
- pdf2pic GitHub repository – The library used for PDF to image conversion.
- n8n Documentation – General information about creating and using custom nodes.