iText pdf library
Website search

How do I rotate a PDF page to an arbitrary angle?

I need to rotate a PDF page by an arbitrary angle, but it seems that the functionality to rotate pages is restricted to multiples of 90 degrees.

The contents of the page are vector and text and I need to be able to zoom in on the contents later, which means that I cannot convert the page to an image because of the loss of resolution.

Posted on StackOverflow on Feb 1, 2015 by sdmorris

Please read ISO-32000-1 (this is the ISO standard for PDF), more specifically Table 30 ("Entries in a page object"). It defines the Rotate entry like this (literal copy/paste):

The number of degrees by which the page shall be rotated clockwise when displayed or printed. The value shall be a multiple of 90. Default value: 0.

Whenever an ISO standard uses the word shall, you are confronted a normative rule (as opposed to when the standard uses the word should in which case you're facing a recommendation).

In short: you are asking something that is explicitly forbidden by the PDF specification. Meeting your requirement is impossible in PDF. Your page can have an orientation of 0, 90, 180 or 270 degrees. You will have to rotate the contents on the page instead of rotating the page.

Click this link if you want to see how to answer this question in iText 5.


Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now