wpwing
wpwing

Reputation: 33

How to get height and width of a pdf while using PDF BOX

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

Answers (1)

Juan Ramos
Juan Ramos

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

Related Questions