Thanks much! I'm trying this but it seems to pull in bookmarks, not named destinations. Am I missing something?
On Sat, May 22, 2010 at 11:15 AM, Andreas Lehmkuehler <[email protected]>wrote: > Hi > > Kevin Brown schrieb: > > I can't seem to get this done with pdfbox. There doesn't seem to be a way >> to >> get the page number from the context of the named destination. Am I wrong? >> Anyone got any sample code for working with named destinations? >> > If you have a look at the mentioned example you find some code like this: > > PDDocumentOutline > bookmarks=document.getDocumentCatalog().getDocumentOutline(); > PDOutlineItem item = bookmarks.getFirstChild().getNextSibling(); > > And the PDOutlineItem class provides a method to get the corresponding > page: > > /** > * This method will attempt to find the page in this PDF document that this > outline points to. > * If the outline does not point to anything then this method will return > null. If the outline > * is an action that is not a GoTo action then this methods will throw the > OutlineNotLocationException > * > * @param doc The document to get the page from. > * > * @return The page that this outline will go to when activated or null if > it does not point to anything. > * @throws IOException If there is an error when trying to find the page. > */ > public PDPage findDestinationPage( PDDocument doc ) throws IOException > > I didn't test it, but theoretically it looks like the piece of code you are > looking for. > > BR > Andreas Lehmkühler > > > >> On Wed, May 19, 2010 at 12:45 PM, Kevin Brown <[email protected]> wrote: >> >> Thanks. I do need to do that! >>> >>> At the moment I'm trying to see if I can get the >>> GotoSecondBookmarkOnOpen.java sample has any clues... if PDOutlineItem >>> could refer to a named destination then I may be in business! >>> >>> >>> >>> On Wed, May 19, 2010 at 11:57 AM, <[email protected]> wrote: >>> >>> I haven't dealt with named destinations, but if you get get the object >>>> ID >>>> of the page, you can look up the page number with doc.getPageMap(). If >>>> you haven't already, I'd suggest tracing through a PDF with a hex editor >>>> (or any good quality text editor will work fine) to find out how >>>> everything is connected. >>>> >>>> ---- >>>> Thanks, >>>> Adam >>>> >>>> >>>> >>>> >>>> >>>> From: >>>> Kevin Brown <[email protected]> >>>> To: >>>> [email protected] >>>> Date: >>>> 05/19/2010 08:42 >>>> Subject: >>>> getting page numbers of named destinations >>>> >>>> >>>> >>>> Is it possible to, for a PDF, get the named destinations in it, and find >>>> out >>>> what page each is on? It doesn't look like it from my perusal of the >>>> documentation, but I'm not sure. Seems like you can get the destination >>>> names but that's about it. >>>> >>>> >>>> >>>> ? 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. >>>> >>> >>> >>> >> >

