Thank you, Adam, for the hint. In my case the solution was to use
getAllKids on getDocumentCatalog.getPages instead of getKids on Page's
parent:
List allpages = new ArrayList();
document.getDocumentCatalog().getPages().getAllKids(allpages);
pageNumber = allpages.indexOf(page)+1));
The mentioned pageMap field of PDDocument doesn't seem to be very useful
to me. The public method getPageMap() is never used outside, just inside
and the pages are mapped to an "own" string representation of
(objStr+","+genStr) object and generation number... Just trying to grasp
the API...
Wulf
a...@swmc.com schrieb:
I use the page map to get the object ID and generation from bookmarks.
Here's how (I omitted the iteration over the entire document catalog to
keep it simple):
PDDocumentOutline root = doc.getDocumentCatalog().getDocumentOutline();
PDOutlineItem item = root.getFirstChild();
COSObject targetPageRef =
(COSObject)((COSArray)item.getAction().getCOSDictionary().getDictionaryObject("D")).get(0);
I did a lot of reading of the PDF spec and debugging to figure that one
out. For pages, I'd suggest looking at the parser to see where its read
in and stored; you should be able to figure out how to get it from there.
Hope this helps.
--Adam
From:
Wulf Berschin <bersc...@dosco.de>
To:
pdfbox-users@incubator.apache.org
Date:
11/09/2009 09:04
Subject:
How to get Page Number from a PDPage
Hi,
how do I get the page number of a PDPageXYDestination which returns a
PDPage?
I saw that PDDocument holds a pageMap which maps object/generationnumber
to page numbers but, unfortunately I don't see a way how to get this
object/generationnumber of a PDPage, but porbably I am off the track...
Thanks, Wulf
? Click here to submit conditions
This email and any content within or attached hereto from Sun West Mortgage Company, Inc. is confidential and/or legally privileged. The information is intended only for the use of the individual or entity named on this email. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or the taking of any action in reliance on the contents of this email information is strictly prohibited, and that the documents should be returned to this office immediately by email. Receipt by anyone other than the intended recipient is not a waiver of any privilege. Please do not include your social security number, account number, or any other personal or financial information in the content of the email. Should you have any questions, please call (800) 453 7884.