Hello everybody!
I have the PDF document with bookmarks, those also have child bookmarks.
I need to get the titles of the all bookmarks (parent and child) and also get the page numbers they linked to.
I need to do it by VB6.
I guess that I can use the "Javascript" objects - get bookmarks array by objectJS.bookmarkRoot.Children, then get the name of the each bookmark by "Name" property.
But I have two problems:
1. I need to check if the bookmark has children, I use the following code:
objectBookmarks = objectJS.bookmarkRoot.Children
objectBookmarksChildren = objectBookmarks(Index).Children
If first level bookmark has children there are no problem, but if hasn’t I get the error instead on NULL value (as it is described in the reference guide).
What is the problem? May be I can use another functionality to check children existence?
2. Also I didn’t find the method or property to get the page number that bookmark linked to.
Thanks a lot in advance!!!
To get around the problem write all of the JavaScript part of your code into a fucntion in a Folder Level Script, i.e. the code for collecting all the bookmark info. Then call this function from the JSO in the VB program. The function should return a string or array that can then be easily parsed on the VB side. I prefer XML since both VB.NET and JS have built-in XML parsers. This method is also more efficient since it separtes the JavaScript only part into it's native environment.
The answer to your second question is that a bookmarks destination is not directly available. However, the easiest way to find out where a bookmark leads is to follow it, use the "bookmark.execute()" fucnction.
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script