How to rotate a page 90 degrees?

I am trying to use a PDF for stamping and need to rotate it 90 degrees to lay it on correctly? Anyone know how to do this? Posted on StackOverflow on Nov 19, 2014 by Casey Please take a look

I am trying to use a PDF for stamping and need to rotate it 90 degrees to lay it on correctly? Anyone know how to do this?

Posted on StackOverflow on Nov 19, 2014 by Casey

Please take a look at the Rotate90Degrees example.

In this example, we create a PdfDocument to get an instance of the document, and just change the /Rotate value in every page dictionary (if there is no such entry, we add one with value 90):

PdfDocument pdfDoc = new PdfDocument(new PdfReader(src), new PdfWriter(dest));
int n = pdfDoc.getNumberOfPages();
PdfPage page;
PdfNumber rotate;
for (int p = 1; p 

Once this is done, we use pdfDoc.close() to persist the change.

If you want an iText for C# example, you'll discover that it is very easy to port the Java to C# as the terminology is identical.

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


Share this article

Ready to use iText?

Try our iText 7 Library and add-ons FREE for 30 days. Test your proof of concept, and see if our solution is right for you.

Get my FREE trial
Contact

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