Return-Path: X-Original-To: apmail-pdfbox-users-archive@www.apache.org Delivered-To: apmail-pdfbox-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 758F710C47 for ; Fri, 8 Nov 2013 15:41:10 +0000 (UTC) Received: (qmail 96689 invoked by uid 500); 8 Nov 2013 15:40:53 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 93540 invoked by uid 500); 8 Nov 2013 15:40:48 -0000 Mailing-List: contact users-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@pdfbox.apache.org Delivered-To: mailing list users@pdfbox.apache.org Received: (qmail 92999 invoked by uid 99); 8 Nov 2013 15:40:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Nov 2013 15:40:38 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of news4sera@gmx.de designates 212.227.17.21 as permitted sender) Received: from [212.227.17.21] (HELO mout.gmx.net) (212.227.17.21) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Nov 2013 15:40:31 +0000 Received: from sabrinas-pc.upc.de ([109.91.185.16]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0Lg0sd-1Vz51c1qjD-00pe5C for ; Fri, 08 Nov 2013 16:40:11 +0100 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: users@pdfbox.apache.org Subject: Re: bookmark.getDestination is null References: Date: Fri, 08 Nov 2013 16:40:13 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Sera Message-ID: In-Reply-To: User-Agent: Opera Mail/12.16 (Win32) X-Provags-ID: V03:K0:CTYjA/iuBax1ST6u6zT5ExSuA2Df2OfvzdUDKn5CuUALX+jabVn gXyF89rmZYbtqT9PLzOCoyEBBow5x+WKFrGzp5SAYWV/ANA26SHbD7hB3ODtUMKh/fEzvyk J4Cao2PczRnIBipOcXR5MmjQq6RW4yucBBOhT0AoM5adWdONal2wkVxtB1ts8NIF9ab0vcE egBctJMqPdf3iptf9SJqQ== X-Virus-Checked: Checked by ClamAV on apache.org First, thanks for the code! Unfurtanately, I still get a Nullpointer. dests.getNames() is null. Am 04.11.2013, 13:38 Uhr, schrieb Gilad Denneboom : > You wrote the following code to do it: > > public static int getPageNumberFromNamedDestination(PDDocument doc, > String name) throws IOException { > PDDestinationNameTreeNode dests = > doc.getDocumentCatalog().getNames().getDests(); > if (dests==null || dests.getNames()==null) > return -1; > Object d = dests.getNames().get(name); > if (d==null) > return -1; > return getPageDestPageNumber(d); > } > > public static int getPageDestPageNumber(Object dest) { > > if (dest instanceof PDPageFitDestination) { > PDPageFitDestination pageFitDestination = > (PDPageFitDestination) dest; > return pageFitDestination.findPageNumber(); > } > > if (dest instanceof PDPageXYZDestination) { > PDPageXYZDestination pageXYZDestination = > (PDPageXYZDestination) dest; > return pageXYZDestination.findPageNumber(); > } > > if (dest instanceof PDPageFitWidthDestination) { > PDPageFitWidthDestination fitWidthDestination = > (PDPageFitWidthDestination) dest; > return fitWidthDestination.findPageNumber(); > } > > if (dest instanceof PDPageFitHeightDestination) { > PDPageFitHeightDestination fitHeightDestination = > (PDPageFitHeightDestination) dest; > return fitHeightDestination.findPageNumber(); > } > > if (dest instanceof PDPageFitRectangleDestination) { > PDPageFitRectangleDestination pageFitRectangleDestination = > (PDPageFitRectangleDestination) dest; > return pageFitRectangleDestination.findPageNumber(); > } > > return -1; > } > > > On Sun, Nov 3, 2013 at 1:39 PM, Sera wrote: > >> I've debugged it and it throws an exception. >> >> >> PDDestinationNameTreeNode node = (PDDestinationNameTreeNode) >> document.getDocumentCatalog().getStructureTreeRoot().getIDTree(); >> >> any idea what the correct way is? >> >> >> >> Am 01.11.2013, 23:47 Uhr, schrieb Sera : >> >> >> >>> is this the right way to get to the treenode? >>> >>> Am 31.10.2013, 11:28 Uhr, schrieb Gilad Denneboom < >>> gilad.denneboom@gmail.com>: >>> >>> If the destination is a PDNamedDestination object, you have to cast >>> it to >>>> that class... >>>> >>>> >>>>> >>>> On Thu, Oct 31, 2013 at 11:24 AM, Sera wrote: >>>> >>>> Do I have to cast Action to another type than ActionGoTo? I don't >>>> see a >>>>> function getNamedDestination() in the suggestions for my objects. >>>>> >>>>> Am 31.10.2013, 10:45 Uhr, schrieb Gilad Denneboom < >>>>> gilad.denneboom@gmail.com>: >>>>> >>>>> Ah, so your bookmarks are not pointing to page locations directly, >>>>> but >>>>> to >>>>> >>>>>> Named Destinations. This makes things more complex. You can use >>>>>> getNamedDestination() to get the name of the ND the bookmark is >>>>>> pointing >>>>>> to. Of course, then you still need to write a function that looks up >>>>>> that >>>>>> specific ND in the tree (a PDDestinationNameTreeNode object) and >>>>>> then >>>>>> figures out to which page it's pointing to by its value. >>>>>> >>>>>> >>>>>> On Thu, Oct 31, 2013 at 10:35 AM, Sera wrote: >>>>>> >>>>>> when i make it toString() i get: >>>>>> >>>>>>> >>>>>>> org.apache.pdfbox.pdmodel.****interactive.****documentnavigation.** >>>>>>> destination.****PDNamedDestination@505484dc >>>>>>> >>>>>>> >>>>>>> whereas the last after @ is always different. I think its the >>>>>>> hashed >>>>>>> destination? >>>>>>> >>>>>>> Am 31.10.2013, 10:20 Uhr, schrieb Gilad Denneboom < >>>>>>> gilad.denneboom@gmail.com>: >>>>>>> >>>>>>> >>>>>>> What do you mean by "hascode", exactly? >>>>>>> >>>>>>> >>>>>>>> >>>>>>>> On Thu, Oct 31, 2013 at 10:16 AM, Sera wrote: >>>>>>>> >>>>>>>> ok, now I've got the destination as a hashcode. How do I get the >>>>>>>> >>>>>>>> pagenumber from this? >>>>>>>>> >>>>>>>>> Am 30.10.2013, 20:10 Uhr, schrieb Gilad Denneboom < >>>>>>>>> gilad.denneboom@gmail.com>: >>>>>>>>> >>>>>>>>> >>>>>>>>> Like I said, you need to determine (using instanceof, for >>>>>>>>> example) >>>>>>>>> which >>>>>>>>> >>>>>>>>> actual class it is, one of the subsets of PDAction, like >>>>>>>>> PDActionGoTo >>>>>>>>> >>>>>>>>>> ... >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On Wed, Oct 30, 2013 at 7:51 PM, Sera wrote: >>>>>>>>>> >>>>>>>>>> current.getAction() is just a PDAction. From there I don't have >>>>>>>>>> access >>>>>>>>>> to >>>>>>>>>> >>>>>>>>>> getDestination(). >>>>>>>>>> >>>>>>>>>>> Am 30.10.2013, 16:27 Uhr, schrieb Gilad Denneboom < >>>>>>>>>>> gilad.denneboom@gmail.com>: >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> You should get the Action of the bookmark, and then check >>>>>>>>>>> which >>>>>>>>>>> type >>>>>>>>>>> of >>>>>>>>>>> >>>>>>>>>>> action it is (probably PDActionGoTo), and from the Action >>>>>>>>>>> you'll >>>>>>>>>>> have >>>>>>>>>>> >>>>>>>>>>> access to the Destination. >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> On Wed, Oct 30, 2013 at 4:00 PM, Sera >>>>>>>>>>>> wrote: >>>>>>>>>>>> >>>>>>>>>>>> Hello! >>>>>>>>>>>> >>>>>>>>>>>> I need to extract the pagenumber out of the bookmarks and >>>>>>>>>>>> tried >>>>>>>>>>>> it >>>>>>>>>>>> >>>>>>>>>>>> with >>>>>>>>>>>>> >>>>>>>>>>>>> PDOutlineItem current = bookmark.getFirstChild(); >>>>>>>>>>>>> PDDestination destination = null; >>>>>>>>>>>>> destination = current.getDestination(); >>>>>>>>>>>>> >>>>>>>>>>>>> But the destination stays null. Any ideas on how to fix this? >>>>>>>>>>>>> >>>>>>>>>>>>> Regards, >>>>>>>>>>>>> Sera >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> -- >>>>>>>>>>>>> >>>>>>>>>>>>> Erstellt mit Operas E-Mail-Modul: http://www.opera.com/mail/ >>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> >>>>>>>>>> Erstellt mit Operas E-Mail-Modul: http://www.opera.com/mail/ >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>> Erstellt mit Operas E-Mail-Modul: http://www.opera.com/mail/ >>>>>>> >>>>>>> >>>>>>> >>>>> -- >>>>> Erstellt mit Operas E-Mail-Modul: http://www.opera.com/mail/ >>>>> >>>>> >>> >>> >> >> -- >> Erstellt mit Operas E-Mail-Modul: http://www.opera.com/mail/ >> -- Erstellt mit Operas E-Mail-Modul: http://www.opera.com/mail/