Rotation is a page flag, not a redraw
Every page in a PDF carries a /Rotate entry. It tells a viewer to turn the page clockwise by a multiple of 90 degrees when displaying or printing it. Rotating here only edits that entry, using pdf-lib's setRotation. The page's text, images and fonts are never touched, which is why nothing is re-compressed and text remains selectable. The viewer does the turning.
The calculation is cumulative. For each target page the tool reads the current rotation and applies (current + angle) % 360. This matters because many scanned files already carry a rotation flag.
Worked example
| Page's existing /Rotate | Option chosen | New /Rotate |
|---|---|---|
| 0 | 90° clockwise | 90 |
| 90 | 90° clockwise | 180 |
| 270 | 90° clockwise | 0 |
| 0 | 90° counter-clockwise | 270 |
| 180 | 180° | 0 |
The "counter-clockwise" option is simply a 270-degree clockwise turn, so rotating the same page twice with it takes you to 180.
Choosing pages and avoiding surprises
With "Rotate all pages" ticked, every page is turned. Untick it to type a selection like 1-2, 4; pages outside the document are ignored and duplicates are removed. The output is always downloaded as rotated.pdf.
- Only the fixed page changes. A scanned stack with one sideways sheet needs only that page number, not the whole file. Rotating everything would flip the good pages sideways.
- Apply it once per direction. Because rotation accumulates in the saved file, running a 90-degree turn twice on purpose gives 180 degrees. Reload the original if you want to start over.
- Viewers differ on "wrong" flags. A page can look upright in one reader and sideways in another when its content is drawn sideways and the flag compensates. Check the result in the viewer your recipient will use.
- Encrypted PDFs fail. You will get "Could not rotate this PDF" until the password is removed.
Once pages are upright, you can join documents with Merge PDF or trim them with Extract PDF Pages.