Why rotating a PDF should not change its size
A rotated PDF should be the same size as the original. If it is not, the tool re-rendered your pages. How lossless rotation works and how to check that you got it.
Rotate a 400 KB PDF and get back a 3 MB file, or a blurry one, and the tool did more than rotate. It drew each page into an image and turned the image. That is the wrong way to rotate a PDF, and it is easy to check for.
How a PDF stores rotation
Every page in a PDF has a /Rotate entry: 0, 90, 180 or 270. A viewer reads the page content, then turns it by that angle when it shows it. The content itself, the text, fonts and pictures, does not know which way is up.
So rotating a page properly means changing one number. Nothing else in the file has to change.
What re-rendering costs you
Some tools rotate by rasterizing: they draw the page to a bitmap, turn the bitmap, and put it back in a new PDF. You lose:
- Text. The page becomes a picture, so search and copy stop working unless the tool runs OCR.
- Sharpness. Vector text and line art become pixels at whatever resolution the tool picked.
- Size. A page of text that was 20 KB becomes a 300 KB image.
How to check your tool
Rotate a text PDF and look at three things:
- File size. It should be within a few hundred bytes of the original.
- Text. Search for a word you know is on the page. It should be found.
- Zoom. Zoom to 400%. Text edges should stay sharp, not pixelated.
How the JustAPI rotate works
The PDF Rotate API changes the /Rotate value of each page you list and saves the file. Nothing is decoded or re-encoded. The response includes stats.pages_rotated so you can confirm how many pages changed.
This also means rotating is safe to repeat. Turning a page by 90 four times brings it back exactly to where it started, with the same bytes inside.
One caveat
Because rotation is a viewer instruction, a few old tools that ignore /Rotate will still show the page the old way. Every current browser, Acrobat, Preview and mobile viewer respects it. If you must feed a tool that ignores it, convert the pages to images with the PDF to Image API, which renders them the way they are shown.
The free PDF rotator uses the same method. Try it on a text PDF and check the size yourself.