Copy link to clipboard
Copied
Hello,
I am writing a C++ Acrobat plug-in and I am new to the Acrobat SDK.
What my plug-in currently does: Recursively iterates through all bookmarks, starting at the root, and gets the title for each bookmark.
My goal: Determine the page number associated with each bookmark (if there is one) and then re-order all the pages in the document according to the order of the bookmarks.
My problem: After reading through the Acrobat SDK, I cannot find a way to determine the page number for a given bookmark. So far I have tried:
// get the action for the current bookmark
PDAction bookmarkAction = PDBookmarkGetAction(aBookmark);
// get the view destination for the current bookmark's action
PDViewDestination bookmarkViewDestination = PDActionGetDest(bookmarkAction);
Am I headed down the right path? Does the PDViewDestination
contain some other object that will give me the page number for this bookmark? Or at least let me determine if there is a page number for the bookmark?
Or maybe I need to actually "go to" each bookmark destination. Then, once I have programmatically "clicked" on the bookmark, I could determine what page the bookmark was pointing at by checking the page number of the active document. I have tried the following code, but it doesn't actually move the document to a different page like I expected it to:
// open the current bookmark
PDBookmarkSetOpen(aBookmark, true);
Thank you in advance for any help you're able to provide. I'm still very new to the Acrobat SDK and I look forward to learning more.
You should check the subtype of the PDBookmark first to make sure that you are only processing "GoTo" actions (a bookmark can do many things, going to a page view is only one potential action). Then, when you get the PDViewDestination, you should process it via PDViewDestResolve(), so that if you end up with a named destination, you will get a real PDViewDestination. And then, you can information about the target page using PDViewDestGetAttr().
Keep in mind that you can also use JavaScript to "f
...Copy link to clipboard
Copied
You should check the subtype of the PDBookmark first to make sure that you are only processing "GoTo" actions (a bookmark can do many things, going to a page view is only one potential action). Then, when you get the PDViewDestination, you should process it via PDViewDestResolve(), so that if you end up with a named destination, you will get a real PDViewDestination. And then, you can information about the target page using PDViewDestGetAttr().
Keep in mind that you can also use JavaScript to "fake" a GoTo action. This process would not find such an action.
Copy link to clipboard
Copied
I'd say your prerequisite study is the PDF Tefernce to see the internal structure of bookmarks, actions and destinations. (Big document but that's quite self-contained)
You'll see that the idea of "page for a bookmark" is quite tenuous except in certain very specific cases. Common but specific. Armed with this you can pick apart the bookmarks to see thebones applicable and their target page.
Pethsos worst is JavaScript bookmarks which are quite common.
Copy link to clipboard
Copied
Thank you both for your quick responses. I have been using the PDF Reference document and it has been very helpful so far.
Karl,
I have implemented a check on the "sub-type" of each bookmark as you suggested. However, I have not been able to find any useful information regarding the two functions you recommended: PDViewDestResolve() and PDViewDestGetAttr().
Here is what I have so far:
// if the current bookmark has a "GoTo" action, then determine the page number
if (subTypeName = "GoTo"){
// get the active PDF document
AVDoc currentAVDoc = AVAppGetActiveDoc();
PDDoc currentPDDoc = AVDocGetPDDoc(currentAVDoc);
// get the destination for this bookmark's action
PDViewDestination bookmarkViewDestination = PDActionGetDest(bookmarkAction);
// resolve the view destination relative to the active PDF document
bookmarkViewDestination = PDViewDestResolve(bookmarkViewDestination, currentPDDoc);
}
To be honest, I'm not even sure how the PDViewDestResolve()
function is meant to be used because I simply can't find any documentation or examples for it.
The PDViewDestGetAttr()
function seems to be expecting several parameters such as a page number, fit, rectangle, zoom level, etc. My goal here is to extract all of these attributes from the view destination, so how would I be able to provide those parameters to the function if I don't know their values yet?
Thank you for your help so far. I look forward to hearing back from you.
Copy link to clipboard
Copied
All you need should be in the API documentation:
PD_Layer.PDViewDest (Acrobat) - PDViewDestResolve()​
PD_Layer.PDViewDest (Acrobat) - PDViewDestGetAttr()
As far as the arguments to PDViewDestGetAttr() go, this is just plain old C/C++ pass by reference. The function will fill in the values, but you have to provide a reference to your variables.
Copy link to clipboard
Copied
Thank you so much for this. That's exactly what I needed.
I guess I should have mentioned that I'm also brand new to C++. As soon as I read your last reply it made complete sense.
With your help, I have gotten everything done that I needed as far as the Acrobat SDK in concerned. Now I just have to work out a few issues regarding my lack of knowledge in C++.
I can't thank you enough for your help!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now