Retrieving the orientation of a PDF document that has been read through iText

I read in PDF via iText. How can I check if the orientation of the first page is in landscape or portrait mode?

+4
source share
2 answers

Try getPageRotation() in combination with getPageSize()

+3
source

I use this and it seems to work well.

 Rectangle rectangle = pdfReader.getPageSizeWithRotation(pageNumber); if(rectangle.getHeight() >= rectangle.getWidth()) return PageFormat.PORTRAIT; else return PageFormat.LANDSCAPE; 
+4
source

All Articles