I am able to convert the PDF pages into individual images. But I want to read the resolution (dpi), length and height of the PDF before converting to images. Please, how to know these metadata of the PDF in Java using pdfbox
?
3
votes
1 Answers
3
votes
Generally: Pdf is vector-based, so there is no fixed resolution. You can render it in any resolution.
But there is a way to get the information you want. Following method returns a dimension of the page:
PDRectangle cropBox = page.findCropBox();
Dimension dimension = cropBox.createDimension();
By comparing this dimension with the size of a document (AdobeReader -> File -> Properties), it looks like the default dpi is 72. With this information you can calculate the width and height of the page.