Clioos › Guides › Rotate PDF Pages
How to Rotate PDF Pages
A scanned page that came out sideways, or a landscape page in a portrait document — rotating fixes it without touching the content. The free way is one command with qpdf, or a short pypdf script. Here is the exact flow, tested.
At a glance
- qpdf --rotate turns one page or all pages 90, 180, or 270 degrees.
- Pages are 1-based: :1 is the first page, :1-3 is pages 1 to 3. :0 fails.
- Tested 6 November 2026: a 3-page PDF rotated cleanly — all pages at 90 degrees, 2,372 bytes.
- Rotation is a display flag: the page box stays portrait, viewers just show it turned.
- PDF Probe does not rotate pages. It converts PDF tables to Excel — a different job.
Steps
- Install qpdf (free, open source): on Linux
sudo apt install qpdf; on macOSbrew install qpdf. The test used qpdf 11.9.0. - Rotate one page:
qpdf --rotate=+90:1 input.pdf output.pdf— only page 1 turns; the rest stay as they were. - Rotate all pages:
qpdf --rotate=+90:1-3 input.pdf output.pdf— on the test file this set all 3 pages to 90 degrees. Use:1-zwhen you do not know the page count. - Check the result: open the output and confirm the pages show upright. On the test file the output was 2,372 bytes, barely different from the 2,670-byte original.
- No qpdf? pypdf does the same in a script (see the section below):
page.rotate(90)on each page you want turned.
Worked example (tested 6 November 2026)
I tested this with a 3-page A4 PDF (2,670 bytes). With pypdf, page.rotate(90) on page 1 set its /Rotate flag to 90 and saved a 2,240-byte file. With qpdf, --rotate=+90:1 turned page 1 only (2,370 bytes, page 2 still at 0), and --rotate=+90:1-3 turned all three (2,372 bytes, all pages at 90). One gotcha: page ranges are 1-based — --rotate=+90:0 fails, because there is no page 0.
from pypdf import PdfReader, PdfWriter
reader = PdfReader('input.pdf')
writer = PdfWriter()
for page in reader.pages:
writer.add_page(page)
writer.pages[0].rotate(90) # first page only
with open('rotated.pdf', 'wb') as f:
writer.write(f)
What it can't do (tested)
- Reflow text: rotating does not reflow or re-lay-out anything. The text, images, and margins turn with the page, exactly as they were.
- Change the page box: rotation is a display flag — the page box stays 595 by 842 points (portrait A4) and the viewer shows it turned. A few older tools ignore the flag and show the page unrotated.
- Fix upside-down scans: it does turn them — use +180 for a page that is upside down, +270 for one turned the other way.
- Rotate by other angles: only 90, 180, and 270 degrees. A 45-degree turn is not a rotation a PDF page supports.
Free alternatives, honestly compared
- pypdf: the script above — best when rotation is one step in a bigger job (split, merge, stamp, then rotate).
- Preview on macOS: open the PDF, select pages, Tools > Rotate Left, then save. Quick for one file, manual for many.
- Online rotators: they upload your file to someone else's server. Never use one for bank statements, contracts, or anything sensitive — the file leaves your machine.
PDF Probe does not rotate pages. It converts PDF tables and bank statements to Excel — if that is the job, see How to Convert PDF to Excel.
Frequently asked questions
Can I rotate just one page?
Yes. With qpdf, --rotate=+90:1 turns page 1 only. With pypdf, call rotate(90) on the one page you want.
What angles can I use?
90, 180, or 270 degrees. A PDF page cannot be rotated by any other angle — 45 degrees is not supported.
Will rotating change the file size?
Barely. The test file went from 2,670 bytes to 2,372 bytes after rotating all 3 pages — rotation only sets a flag, it does not re-encode the content.
Why does my rotated page still look sideways in one viewer?
Some older viewers ignore the /Rotate flag. Open the file in a modern browser or PDF reader to check — most handle it correctly.
Related guides: How to Split a PDF · How to Merge a PDF · How to Edit a PDF · How to Unlock a PDF · All guides · Tool: PDF Probe