Reputation: 33
Here is a question: When I use PDF Box, I have no idea how to get height and width of a PDF file. I cannot see any method for get.
PDDocument pdDocument = getPDDocument(fis);
PDPage doc = pdDocument.getPage(0);
Upvotes: 3
Views: 8237
Reputation: 577
Inside of each PDPage
you have a method called getMediaBox()
that returns a PDRectangle
. You can obtain the height and the width.
Be careful with the UOM that represent the width and height.
https://pdfbox.apache.org/docs/2.0.0/javadocs/org/apache/pdfbox/pdmodel/PDPage.html#getMediaBox()
Upvotes: 4