Reputation: 571
I'm using PDFBox, successfully to retrieve field coordinates from PDFs. Moving on to multi-page PDFs, I ran into the situation where I need to determine from which page these fields are coming from, and additionally to convert the coordinates from bottom-up to top-down. I've read through numerous pages of the doc to find a method that would work, most return null, or fail, and there are no results upon search.
What am I looking for? Document outline? BBbos? mediaBox? cropBox?
And for page number, a few other libraries have such simply titled methods as getCurrentPageNo(). Would I need to:
List allPages = document.getDocumentCatalog().getAllPages();
for (int i = 0; i < allPages.size(); i++) {
// etc for each one?
}
This is such a core ability, I'm somewhat surprised I haven't found an example yet.
Upvotes: 1
Views: 1888
Reputation: 571
Got it:
PDPage page = .........
PDRectangle mediaBox = page.getMediaBox();
System.out.println( "Width:" + mediaBox.getWidth() );
System.out.println( "Height:" + mediaBox.getHeight() )
for the page number:
page.getCOSDictionary().equals(page))
Upvotes: 1