thanks, I changed my code as shown below. However I can't cast the destination to the PDPageXYZDestination and it appears that it is a PDPageFitWidthDestination class. This class does not have the getLeft() and the page number returns -1????
PDDocumentOutline outline = pdfDoc .getDocumentCatalog().getDocumentOutline(); if (outline != null) { debugMsg2("found outline"); PDOutlineItem current = outline.getFirstChild(); while (current != null) { debugMsg2 (current.getTitle()); if ("Image" .equalsIgnoreCase(current.getTitle())) { PDActionGoTo action = (PDActionGoTo) current.getAction(); if (action != null ) { PDPageFitWidthDestination dest = (PDPageFitWidthDestination) action.getDestination(); if (dest != null) { // debugMsg2("left: " + dest.getLeft()); debugMsg2("top: " + dest.getTop()); debugMsg2("page: " + dest.getPageNumber()); } else { debugMsg2("dest is null"); } } else { debugMsg2( "action is null"); } current = current.getNextSibling(); } } } else { debugMsg2("This document does not contain any bookmarks"); } Howard Howard Greenberg, CPA, CISA IBM Certified Application Developer/Instructor - IBM Notes and Domino The Learning Continuum Company, Ltd. 888-241-8522 or 561-953-0096 http://www.tlcc.com mailto:howa...@tlcc.com From: Tilman Hausherr <thaush...@t-online.de> To: users@pdfbox.apache.org Date: 12/01/2016 03:49 PM Subject: Re: question on getting location of bookmark Am 01.12.2016 um 21:38 schrieb howa...@tlcc.com: > thanks, I am missing something... My code uses getDestination() and > recasts as PDPageXYZDestination. However, the dest is null. I must be > missing something? There's anther possibilty, that there is an /A entry, i.e. an action. Call getAction(). There are 13 different types of actions, but I'd expect PDActionGoTo. On that one you can again call getDestination(). Tilman > > PDDocumentOutline outline = pdfDoc > .getDocumentCatalog().getDocumentOutline(); > if( outline != null ){ > debugMsg2("found outline"); > PDOutlineItem current = > outline.getFirstChild(); > while( current != null ) { > debugMsg2( current.getTitle() ); > if ("Image" > .equalsIgnoreCase(current.getTitle())){ > PDPageXYZDestination dest > = (PDPageXYZDestination) current.getDestination(); > if (dest!=null){ > debugMsg2("left: " > + dest.getLeft()); > debugMsg2("top: " > + dest.getTop()); > debugMsg2("page: " > + dest.getPageNumber()); > } else { > debugMsg2("dest is > null"); > } > } > current = > current.getNextSibling(); > } > > > } else { > debugMsg2( "This document does not contain > any bookmarks" ); > } > > > Howard > Howard Greenberg, CPA, CISA > IBM Certified Application Developer/Instructor - IBM Notes and Domino > The Learning Continuum Company, Ltd. > 888-241-8522 or 561-953-0096 > http://www.tlcc.com > mailto:howa...@tlcc.com > > > > From: Tilman Hausherr <thaush...@t-online.de> > To: users@pdfbox.apache.org > Date: 12/01/2016 03:15 PM > Subject: Re: question on getting location of bookmark > > > > Am 01.12.2016 um 21:12 schrieb howa...@tlcc.com: >> thanks, can you elaborate? The API doc for getDestination shows that >> returns PDDestination and I don't see any methods that return the >> coordinates? > There are 7 derived classes. That's why I mentioned that there are > several types. For example, PDPageXYZDestination has a getLeft() and > getTop() method. But not all of the derived classes have coordinates > like that. > > Tilman > >> >> >> Howard >> Howard Greenberg, CPA, CISA >> IBM Certified Application Developer/Instructor - IBM Notes and Domino >> The Learning Continuum Company, Ltd. >> 888-241-8522 or 561-953-0096 >> http://www.tlcc.com >> mailto:howa...@tlcc.com >> >> >> >> From: Tilman Hausherr <thaush...@t-online.de> >> To: users@pdfbox.apache.org >> Date: 12/01/2016 03:03 PM >> Subject: Re: question on getting location of bookmark >> >> >> >> Am 01.12.2016 um 21:00 schrieb howa...@tlcc.com: >>> I want to find the x,y position of a bookmark in the pdf to be able to >>> insert an image at that location. >>> >>> I can get the bookmark with the code below and looping through to find >> the >>> one I need with getTitle.... >>> PDOutlineItem current = outline.getFirstChild(); >>> >>> But, how would I use PDOutlineItem to get the page/location to pass as >> the >>> x,y coordinates in contentStream.drawImage(img, 100, 100); >> call getDestnation(). There are several types, and some of them have >> coordinates. >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org >> For additional commands, e-mail: users-h...@pdfbox.apache.org >> >> >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > For additional commands, e-mail: users-h...@pdfbox.apache.org > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org