I am doing project in Java using PDFBOX-1.8.6 library (its compulsory to use). My Question is
Assuming that you have a PDPage object:
PDRectangle mediaBox = page.findMediaBox();
boolean isLandscape = mediaBox.getWidth() > mediaBox.getHeight();
however... the page could be rotated:
int rotation = page.findRotation();
if (rotation == 90 || rotation == 270)
isLandscape = !isLandscape;
This is for 1.8.* only. In the 2.* versions, use getMediaBox()
and getRotation()
. Don't use the get*
methods in the 1.8.* versions because they don't look up the page tree if the info is missing at the page level.