I have a VB6 module that is inserting a bookmark into a PDF via JSObject. This is working great except that all of the bookmarks are off of the root. I would like to add new bookmarks under a parent (as determined by a string passed). I can't seem to get the insert into the correct position in the tree.
This is the code for finding the parent and it works well but I cannot get any further to insert in the correct position:
Set oJSO = oPDDoc.GetJSObject
Set oBookMarkRoot = oJSO.bookmarkRoot
oBookMarks = oBookMarkRoot.children
iBookMarkCount = UBound(oBookMarks)
For i = 0 To iBookMarkCount
If oBookMarks(i).Name = sParentName Then
'I would like to get the parent's children to determine the position
'to add the new bookmark but I cannot seem to get the child bookmarks
'The following code does not work and throws an error
oPBookmarks = oBookMarks(i).children
iParent = i
Exit For
End If
Next
Any help with getting the insert into the correct position, under the parent, would be greatly appreciated. ALso, the bookmarks also seem to be inserting at the top of the tree each time, instead of at the end of the tree. I may have this fixed but if anyone has any input on this it is appreciated.
Thanks,
The best strategy for using the JSO is to write all of the JavaScript code into a Folder Level Function, then call the function from your VB program. This way there is no incompatibility issue.
You can read about Folder level scripts here:
http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/folder_level_scripts/
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script