PDFToImageNode
PDFToImageNode turns pages into images
- IMAGE
LLMs are great at reading text. Vision models are great at reading images. A PDF is a document that is neither, cleanly, until you rasterize it - which is exactly what PDFToImageNode does. Feed it a PDF path, and it comes out the other end as a ComfyUI IMAGE batch, one image per page. From there you can preview it, run it through image nodes, or hand it to a vision LLM to caption, summarize, or extract data from the document.
How it works
Four required inputs, one output:
- pdf_path - the file path. The code checks the file exists before rendering, and raises a clear
FileNotFoundErrorif not. - dpi - render resolution, 72–600, default 200. PDF pages are vector-defined, so DPI is the quality knob: 200 is a decent balance for OCR/vision, crank to 300+ if the text is tiny. The node computes a zoom factor of
dpi / 72and renders with PyMuPDF. - first_page - 1-based page number to start at (default 1).
- last_page - where to stop;
-1(the default) or any value<= 0means "to the end." Values past the last page also clamp to the end.
Output is IMAGE - a single batched tensor of shape (pages, H, W, 3), normalized 0–1, exactly what ComfyUI's image previews and vision nodes expect. Pages render as RGB; if a page somehow comes back with the wrong channel count the node skips it with a warning rather than corrupting the batch.
A dependency you'll have to add yourself
Here's the gotcha: the node imports pymupdf (PyMuPDF), and pymupdf is not in the pack's requirements.txt. The pack installs fine, then this node dies with ModuleNotFoundError the first time you run it. One-time fix:
cd ComfyUI/custom_nodes/ComfyUI_LiteLLM
pip install pymupdf
Then restart ComfyUI. On Windows use the same python that runs ComfyUI (often python_embeded\python.exe -m pip install pymupdf).
Where people trip
- Pages must be the same size. The node stacks all rendered pages into one batch, and stacking fails if pages end up with different dimensions - even at the same DPI, PDFs can have mixed page sizes (portrait + landscape, or one A4 and one A3). The error message calls this out explicitly. If you hit it, render the offending range in two passes, or pre-process the PDF.
- First page is 1, not 0. The input is 1-based for humans; the code converts internally. People coming from Python habits type 0 and get an off-by-one.
- Path problems are the #1 error. This is a string input, not a file picker. Absolute paths and correct slashes matter; a typo gives you
FileNotFoundErrorbefore anything renders. There's no built-in file browser, so paste carefully (or wire a file-path node into it).
Installing
Pack-level: ComfyUI Manager → search "LiteLLM" (repo Hopping-Mad-Games/ComfyUI_LiteLLM) → Install → Restart, or clone into ComfyUI/custom_nodes and pip install -r requirements.txt (heavy: litellm, boto3, sentence-transformers, a LightRAG fork). Then add pymupdf per above. No API keys involved - it's pure local rendering.
Bottom line
The missing link between "documents people actually send you" and "vision models that can't read PDFs." It's genuinely handy for building "summarize this report" or "extract table from this page" workflows. Budget a one-line pip install and remember the same-size-pages rule, and it'll quietly do its job.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| pdf_path | STRING | path/to/your/pdf/file.pdf | — |
| dpi | INT | 20072–600 | — |
| first_page | INT | 1 | — |
| last_page | INT | -1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |