Actions2
Convert to Image
AI-generatedOverview
This node processes PDF files by either extracting text content or converting PDF pages into images. It supports input PDFs from binary data or URLs and offers flexible options for output formatting and page selection.
Use cases:
- Extracting clean, AI-friendly text from invoices, reports, or contracts.
- Converting PDF pages to PNG or JPEG images for previews, thumbnails, or further image processing.
- Splitting extracted text by pages or including metadata for detailed document analysis.
Examples:
- Parsing a multi-page contract PDF to extract structured text with minimal cleanup.
- Converting the first 3 pages of a PDF brochure into high-resolution PNG images for a website gallery.
- Fetching a PDF from a URL and extracting raw text for natural language processing.
Properties
| Name | Meaning |
|---|---|
| PDF Source | Source of the PDF file: either "Binary Data" (from a binary property) or "URL" (fetch PDF from a web address). |
| Binary Property | Name of the binary property containing the PDF file (required if source is Binary Data). |
| URL | URL of the PDF file to parse (required if source is URL). |
| Output Property Name | Property name where the extracted content or image info will be stored in the output JSON. |
| Max Pages | Maximum number of pages to process (0 means all pages). |
| Page Range Start | Starting page number (1-based) for processing. |
| Page Range End | Ending page number (0 means last page). |
| Text Formatting | Style of text formatting for extracted content when parsing: - Raw (best for AI) - Smart Layout - Minimal Cleanup - Visual Layout - Structured - Compact |
| Include Metadata | Whether to include PDF metadata (info, version, etc.) in the output JSON. |
| Split by Pages | Whether to split the extracted text output into an array of page texts. |
| Image Format | Output image format when converting: PNG (supports transparency) or JPEG (smaller size). |
| DPI (Resolution) | Dots per inch for image conversion; higher values yield better quality but larger files (range 72–600). |
| Width | Image width in pixels (0 means auto based on DPI). |
| Height | Image height in pixels (0 means auto based on DPI). |
| Preserve Aspect Ratio | Maintain original aspect ratio when resizing images. |
Output
For Parse PDF operation:
- Outputs JSON with the extracted text under the specified output property.
- If "Split by Pages" is enabled, the output is an array of strings, each representing one page's text.
- Optionally includes PDF metadata such as number of pages, document info, and version.
- Additional statistics like text length and word count are included.
For Convert to Image operation:
- Outputs JSON containing an array of objects, each describing a converted page image with properties:
page: page numberwidth,height: dimensions in pixelssize: byte size of the image bufferformat: image format ("png" or "jpeg")binaryProperty: name of the binary property holding the base64-encoded image data
- The binary data for each image page is included in the output under separate binary properties named like
image_page_1,image_page_2, etc., with appropriate MIME types.
- Outputs JSON containing an array of objects, each describing a converted page image with properties:
Dependencies
- Uses the
pdf-parselibrary for PDF text extraction. - Uses the
pdf2piclibrary for converting PDF pages to images. - Requires system dependencies for image conversion:
- GraphicsMagick
- Ghostscript
These must be installed in the n8n environment for the convert operation to work properly.
Troubleshooting
Common issues:
- Invalid or empty PDF input: The node checks that the input starts with "%PDF" and is not empty.
- URL fetch failures: Ensure the URL is valid and accessible.
- Missing system dependencies for image conversion: Errors mentioning missing GraphicsMagick or Ghostscript indicate these are not installed.
Error messages and resolutions:
"URL is required when source is set to URL": Provide a valid URL."Invalid URL format": Check URL syntax."File does not appear to be a valid PDF": Input file is not a proper PDF."PDF to Image conversion failed: Missing system dependencies...": Install GraphicsMagick and Ghostscript in your environment."GraphicsMagick not found": Install GraphicsMagick.- Other conversion errors: Review error details and ensure environment setup matches requirements.