Basically, a bookmark will just have a title and a reference to a page 
object.  Once you get the reference to the page, it's just a matter of 
looking up the object id and determining which page that is (which is 
where the page map comes in handy).  Give your bookmark a unique name, 
save it, then open the PDF in a text editor (vi, emacs, Notepad++, etc.). 
Search for the bookmark title and you should be able to see how the file 
is laid out.  Its actually quite easy to read.  Just have the PDF spec 
handy to look up what each of the numbers mean (you don't have to read the 
whole thing, just jump to the section on bookmarks).

Another nice tactic is to open the debugger and just go through memory 
until you find the object ID you're looking for.  Once you find it, figure 
out how to access it.

--Adam



From:
Tim Reynolds <[email protected]>
To:
[email protected]
Date:
02/24/2010 14:19
Subject:
Re: How to get Page Number from Bookmark conflicting results



Adam,

Thanks for your reply

It looks to me that the content of PDF Bookmarks very widely between PDFs. 

I checked PDF books that I own from 3 different Publishers.  The 
COSBase returned from  PDDestination.getCOSObject() COSArray, COSString, 
COSName, at least those are the ones I found. 

I did download the PDF Spec : 
http://www.adobe.com/devnet/acrobat/pdfs/PDF32000_2008.pdf. I must admit 
its quite lengthy and I have not read 
exactly how to get to the info I need yet.

My goal is to lucene-index the BookMarks, search them and then be able to 
jump to 
the page indicated by the bookmark, I'm not sure yet if this will be 
possible.

I did see this in the examples: GoToSecondBookMarkOnOpen.java
                PDOutlineItem item = 
bookmarks.getFirstChild().getNextSibling();
                PDDestination dest = item.getDestination();
                PDActionGoTo action = new PDActionGoTo();
                action.setDestination(dest);
                document.getDocumentCatalog().setOpenAction(action);
                document.save( args[1] );
maybe this will provide me with some more clues. 

I did attempt several tests on the code snippet you provided but I could 
not get 
the page number when PDAction == null, ie dest != null. As I stated above 
the COSObject
in many cases is not COSArray


 again thanks for you input I will take a closer look at getPageMap().

Tim



 


?  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.   

Reply via email to