How do you rotate a PDF permanently?
You rotate a PDF permanently by changing each page's Rotate value inside the file, so every viewer and printer turns the page the same way. Choose your PDF, pick 90°, 180° or 270°, click Convert, and download rotated.pdf. Every page is turned clockwise by that amount, with no loss of quality.
Why rotation is lossless
A PDF page doesn't store "this page is sideways" as pixels. Each page object can carry a Rotate entry, which the PDF standard defines as the number of degrees the page is turned clockwise when displayed or printed, and it must be a multiple of 90 (ISO 32000-1, page objects in section 7.7.3.3). This tool uses pdf-lib to read each page's current value, add your angle, and write the result back.
Because only that number changes, scanned images aren't resampled, text stays selectable and searchable, and links keep working. It's the same thing a desktop PDF editor does when you rotate and save.
Rotation adds to what's already there
The new angle is added to each page's existing rotation, then wrapped at 360. That matters with files that are already rotated, which is common with scans:
| Page's current rotation | You choose | Saved rotation | Net effect |
|---|---|---|---|
| 0° | 90° | 90° | Quarter-turn clockwise |
| 0° | 270° | 270° | Quarter-turn counter-clockwise |
| 90° | 90° | 180° | Now upside down relative to the original |
| 90° | 270° | 0° | Back to unrotated |
| 180° | 180° | 0° | Back to unrotated |
You can see the wrap-around by running the tool twice: a page rotated 90° and then 270° comes back at 0°. So if you overshoot, run the output through again with the angle that completes the circle rather than starting over.
Picking the right angle
Look at the page as it appears now and ask which way the top of the content points.
- Top of the text points left: choose 90°.
- Top points right: choose 270°.
- Text is upside down: choose 180°.
Since all pages get the same turn, this works best when the whole document is wrong in the same way, such as a stack of landscape scans that came out portrait.
When only some pages are sideways
A mixed document needs a little surgery, because there's no per-page selector. Say pages 4 and 5 of a 12-page report are landscape tables that display sideways:
- Use Split PDF three times to get pages 1 to 3, 4 to 5 and 6 to 12 as separate files (rename each download, since they're all called
split.pdf). - Rotate only the 4 to 5 file here.
- Join the three files in order with the PDF merger.
Rotating and page numbers
Order matters if you also want page numbers. The page number tool reads each page's rotation and stamps the number upright along the bottom edge as the page is displayed. So rotate first, check that every page looks right, then number. If you number first and rotate afterwards, the numbers turn together with the content and end up on a side or top edge.
Limits and errors
- All pages, one angle. Only 90°, 180° and 270° are offered, matching the multiples of 90 the format allows. There's no 45° or free rotation, and no deskew for slightly crooked scans.
- Protected files. pdf-lib refuses any PDF with an encryption dictionary, including files that open without a password but restrict editing. You'll see "Could not rotate that PDF:" followed by a message saying the document is encrypted. Remove the protection in the source program first.
- Damaged or fake PDFs fail with a parse error such as "No PDF header found".
- No file size cap is set in the code. The file is held in memory as base64 text while it's processed, so very large scans are limited by your device's memory.
The output is re-saved with compressed object streams, so its size is usually close to the original's. Document metadata gets pdf-lib's producer name and a new modification date. To see how the result looks as an image, render the first page to PNG.
Last updated