PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)
Moderators:PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
We have a C# application that creates an instance of AxCoPDFXCview and uses the RunJavaScript method to discover the annotations in a document, which we then save to a database. We also read annotations from the database and create them in documents using JS. This works just fine.
I was hoping that the same thing would be possible for bookmarks. I've seen the JS examples that pull the hierarchy of bookmarks out of a document, but I can't seem to figure out the whole cycle as with annotations.
Is it possible to get the page #, X, Y, and zoom from an existing bookmark using JS? The best I've been able to do is execute() an existing bookmark and then see what the current page is.
Is it possible to create a functioning bookmark with JS? When I try the example from the JavaScript for Acrobat API Reference (this.bookmarkRoot.createChild("Next Page", "this.pageNum++");), it creates a bookmark, but nothing happens when you click it in the viewer. I've been trying this from the viewer's JS console (2.5, build 213), but no JS action I have tried works when the created bookmark is clicked.
What am I doing wrong? Can anyone suggest any alternatives for persisting a user's bookmarks to a database?
And the new bookmark certainly works for me and goes to the next page in the document. Can you please make sure you are using the latest builds of our products (214.2 for the Viewer, 307.2 for the Editor).
As you might have noticed however - the Bookmarks methods available in the JS API are sich for creating new bookmarks and for removing existing ones - not for copying the actions associated with a given bookmark - so I do not believe you can achieve the storing of bookmarks in the database using JS.
Also the bookmarks are a document level structure used mostly for navigation inside the same document, but can easily be pointing to other documents or even web links or execute other actions like playing sound etc - so why do you want to store the bookmarks on a per user level in a database? Can't the bookmarks tree just stay in the document?
Build 214.2 of the Viewer still does not create a functioning bookmark for me from JS, but the latest Editor does. Will there be an Editor SDK at some point, or is there one now?
I hear what you're saying about JS not being able to deal with bookmark actions, so maybe we'll have to go a different route.
Can PDF Tools or the low level API create a bookmark with a legitimate "go to page" action (x, y, zoom, etc.)?
Yes the Editor SDK is being worked on and will be released as soon as possible. I tested with the end user Viewer build 214.2 - but it was definitely creating the bookmark and it was working as expected. Two clicks on the same bookmark too soon close after one another would rather trigger renaming it (if I am not clicking the green icon on the left) -but other than that - works flawlessly. I tested in a file with an existing bookmark tree - and the script added a top level one at the beginning of the bookmark tree.
For the moment indeed the Low Level API should allow you to create the needed Outline Dictionary - though you will need to read the PDF specification yourself, and also code this on your own, as we do not provide support for the Low Level API.