n8n-nodes-pdf-png-converter
n8n community node package for converting PDF files to PNG images with support for separate pages or combined long image.
Features
- Multiple Input Sources: Support for binary field input or URL download
- Export Modes:
- Separate images (each page as individual PNG)
- Combined image (all pages in one long PNG)
- Flexible Page Range: Convert specific pages or entire document
- Quality Control: Adjustable DPI for output images (72-600 DPI)
- Error Handling: Robust error handling with continue-on-fail option
- n8n Integration: Full integration with n8n workflow system
Installation
Prerequisites
This node requires the following system dependencies:
- poppler-utils: For PDF to image conversion
- Ubuntu/Debian:
sudo apt-get install poppler-utils
- CentOS/RHEL:
sudo yum install poppler-utils
- macOS:
brew install poppler
- Windows: Download from poppler-windows
- Ubuntu/Debian:
Install the Plugin
- Clone this repository
Install dependencies:
npm install
Build the project:
npm run build
Install the package in your n8n instance:
npm install /path/to/n8n-nodes-pdf-png-converter
Usage
Basic Usage
- Add the "PDF to PNG Converter" node to your workflow
- Configure the input source:
- Binary Field: Use binary data from previous nodes
- URL: Download PDF from a URL
- Choose export mode:
- Separate Images: Each page as a separate PNG file
- Combined Image: All pages in one long PNG
- Set image quality (DPI)
- Optionally specify page range (e.g., "1-3,5,7-9")
- Connect to other nodes or use as workflow output
Input Examples
Binary Field Input
{
"binary": {
"data": {
"data": "base64-encoded-pdf-data",
"mimeType": "application/pdf"
}
}
}
URL Input
Provide a direct URL to a PDF file in the node configuration.
Output Examples
Separate Images Mode
{
"json": {
"success": true,
"totalPages": 3,
"convertedPages": 3,
"exportMode": "separate",
"quality": 200,
"images": [
{
"pageNumber": 1,
"filename": "page_1.png",
"size": 123456
}
]
},
"binary": {
"page_1": {
"data": "base64-encoded-png-data",
"mimeType": "image/png",
"fileExtension": "png",
"fileName": "page_1.png"
},
"page_2": { ... },
"page_3": { ... }
}
}
Combined Image Mode
{
"json": {
"success": true,
"totalPages": 3,
"convertedPages": 3,
"exportMode": "combined",
"quality": 200,
"image": {
"filename": "combined_3_pages.png",
"size": 456789
}
},
"binary": {
"combined_image": {
"data": "base64-encoded-png-data",
"mimeType": "image/png",
"fileExtension": "png",
"fileName": "combined_3_pages.png"
}
}
}
Node Parameters
Parameter | Type | Description | Default |
---|---|---|---|
Input Source | Options | Binary field or URL | binary |
Binary Field | String | Name of binary field (for binary input) | data |
PDF URL | String | URL of PDF file (for URL input) | - |
Export Mode | Options | Separate or combined images | separate |
Image Quality | Number | Output DPI (72-600) | 200 |
Page Range | String | Pages to convert (e.g., 1-3,5) | - |
Page Range Syntax
The page range parameter supports the following formats:
1,3,5
- Specific pages1-3
- Range of pages1-3,5,7-9
- Combination of ranges and specific pages- Empty string - All pages
Error Handling
The node includes robust error handling:
- Invalid PDF files
- Network timeouts for URL downloads
- Missing binary fields
- Invalid page ranges
- System dependency issues
When "Continue on Fail" is enabled, errors will be passed to the output with error details.
Development
Building
npm run build
Development Mode
npm run dev
Linting
npm run lint
npm run lintfix
Formatting
npm run format
Example Workflows
Workflow 1: Convert Uploaded PDF
- HTTP Request Node - Receive file upload
- PDF to PNG Converter - Convert to separate images
- Email Node - Send converted images
Workflow 2: URL-based Conversion
- Webhook Node - Receive URL in request
- PDF to PNG Converter - Convert from URL
- Google Drive Node - Save converted images
License
MIT License - see LICENSE.md file for details.
Support
For issues and support, please create an issue in the repository.