Rotate PDF Pages 🔄📄
Fix sideways scans before they ruin your text and images
- pdf_pages
- PDF_PAGES
Rotate PDF Pages 🔄📄 turns selected pages of a PDF_PAGES list by 90-degree increments. It exists for the most mundane and annoying reason imaginable: someone scanned a document sideways, and now everything downstream is a mess. A rotated page produces rotated text extraction and a rotated image render, so fixing orientation at the page level fixes every consumer of that page at once. One node, all downstream problems solved.
The inputs that matter
pdf_pages(PDF_PAGES) - the pages to rotate.page_selection(STRING, defaultall) - same shared syntax as the text extractor, 1-indexed:1,3,5,2-6,1,3-5,8, orall/empty for everything.rotation_angle(enum, default 0) - a dropdown with exactly four choices:0,90,180,270. That's it. No arbitrary angles, no fine-tuning, which is correct - PDF rotation is only meaningful in 90-degree steps.
How it works, and the subtle part
The mechanism is pypdf's PageObject.rotate(), applied to every selected page. Here's the subtle bit the README won't hammer home: rotate() adds to the page's existing rotation rather than setting it. A page that's already at 90° and gets rotated another 90° ends up at 180°, not back at 0°. So if you're ever unsure of a page's starting orientation, don't guess - and don't chain rotations assuming they reset. The output is a full PDF_PAGES list (rotated pages plus untouched ones), so you can pass it straight into Save, Merge, or the text extractor.
One more mechanic worth knowing: rotation mutates the page objects in place and returns a new list referencing them. In practice each PDFLoad gives you fresh, independent pages, so this rarely bites. But if you wire the same list into both a Rotate and another node, both paths see the rotated result. If that surprises you, duplicate the load instead.
Common issues
- Wrong pages rotated. 1-indexed selection, remember -
1is the first page. If you meant the second page and used2, you got the second page, which is correct; the off-by-one trap only appears if you're also using the 0-indexed single-page select node and mixing mental models. - Rotation doesn't "stick." You rotate, save, and the output looks unchanged - check whether you actually wired Rotate's output into Save PDF (or whether the angle dropdown is still at 0, which returns the list untouched by design).
- Scan detection. If you're rotating to fix sideways scans, do it before text extraction or batch rendering. There's no benefit to extracting sideways text and then rotating.
Install
Same pack install as everything here:
cd ComfyUI/custom_nodes/
git clone https://github.com/orion4d/ComfyUI_pdf_nodes.git
cd ComfyUI_pdf_nodes && pip install -r requirements.txt
Or ComfyUI Manager → "ComfyUI PDF Nodes", restart, and it's under PDF. Needs only pypdf - no image libraries required. It's a boring fix-it node, and like most boring fix-it nodes, it saves you from re-scanning a stack of paper or re-exporting a document, which makes it worth having before you need it.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| pdf_pages | PDF_PAGES | — | |
| page_selection | STRING | all | — |
| rotation_angle | COMBO | 0 | 4 options: 0, 90, 180, 270 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| PDF_PAGES | PDF_PAGES | — |