Copy link to clipboard
Copied
Hello,
I frequently use a bookmark at the top of the Bookmarks List to store the position I stopped reading the last time I was in the document.
You do that by first making the bookmark (I called it "HIER"), and then right-clicking the bookmark, selecting "Set Destination" what connects the current page with the bookmark.
Is there a way I can automate this or designate this in a script to a button?
Copy link to clipboard
Copied
Actually, if you wanted to, you could place that code under a different bookmark and call it "Save Position" or something. It could be just after "HIER" or the last one in the list, or anywhere else. When you click it it will update the HIER bookmark.
Copy link to clipboard
Copied
Got it... This does the trick:
for who wants to try:
/* Set Current position to HIER */
if (this.bookmarkRoot.children==null || (this.bookmarkRoot.children!=null && this.bookmarkRoot.children[0].name!="HIER"))
this.bookmarkRoot.createChild("HIER", "this.pageNum = " + this.pageNum + ";\nthis.zoom = 150;", 0);
else this.bookmarkRoot.children[0].setAction("this.pageNum = " + this.pageNum + ";\nthis.zoom = 150;");
Copy link to clipboard
Copied
A script can only set the action of a bookmark to a script. If you don't mind that then yes, it's possible.
You can achieve it by executing this JavaScript code:
if (this.bookmarkRoot.children==null || (this.bookmarkRoot.children!=null && this.bookmarkRoot.children[0].name!="HIER"))
this.bookmarkRoot.createChild("HIER", "this.pageNum = " + this.pageNum, 0);
else this.bookmarkRoot.children[0].setAction("this.pageNum = " + this.pageNum);
The code will edit an existing bookmark, or create it if it doesn't exist.
Copy link to clipboard
Copied
OK Try67,
Thank you for your answer.
I have added the script to the bookmark,
Finished with twice OK.
Now how do I run this script, so the bookmark "HIER" receives the current page as Destiny?
Do I double-click the bookmark? In that case the script changes to:
(forgive me my ignorance, but I've never worked with script in Acrobat before)
Copy link to clipboard
Copied
Sorry, I wasn't clear enough. That script should not go under the bookmark, because it will get overwritten, as you saw.
You could run it from the JS Console, for example, or even from a menu item or toolbar icon (although you'll need to adjust it a bit and place it in a .js file on the local computer).
Copy link to clipboard
Copied
OK ThanX, I'll look into that.
Copy link to clipboard
Copied
Actually, if you wanted to, you could place that code under a different bookmark and call it "Save Position" or something. It could be just after "HIER" or the last one in the list, or anywhere else. When you click it it will update the HIER bookmark.
Copy link to clipboard
Copied
Well Try67,
I have found the Custom Tools pane and have added the script succesfuly
(added this.zoomType = zoomtype.fitW; too while doing it)
so I am 98% happy (wish I didn't have to confirm the script every time).
ThanX for your help!
Copy link to clipboard
Copied
Actually have worked out your last suggestion too and that indeed works as a sincle click
(makes me100% HAPPY):
ThanX again!
Copy link to clipboard
Copied
Graag gedaan!
Copy link to clipboard
Copied
Any idea, by the way, how I should tweek this script so the result is that the Zoom 150 line becomes part of the HIER output script? I've come to various approaches but no success yet.
This is the current script:
/* Set Current position to HIER */
if (this.bookmarkRoot.children==null || (this.bookmarkRoot.children!=null && this.bookmarkRoot.children[0].name!="HIER"))
this.bookmarkRoot.createChild("HIER", "this.pageNum = " + this.pageNum, "this.zoom = 150", 0);
else this.bookmarkRoot.children[0].setAction("this.pageNum = " + this.pageNum);
I have added "this.zoom = 150", but that doesn't show up in the HIER (result) script:
this.pageNum = 60
Copy link to clipboard
Copied
It has to be a part of the same string, like this:
"this.pageNum = " + this.pageNum + "; this.zoom = 150;"
Copy link to clipboard
Copied
Yes, I tried that, but it doesn't work...
This script
does this:
which should be:
to work...
Copy link to clipboard
Copied
You have to make the same adjustment to the last line of code, too.
Copy link to clipboard
Copied
[This was a reply I sent to another thread. Don't know why it ended up here...]
Copy link to clipboard
Copied
Got it... This does the trick:
for who wants to try:
/* Set Current position to HIER */
if (this.bookmarkRoot.children==null || (this.bookmarkRoot.children!=null && this.bookmarkRoot.children[0].name!="HIER"))
this.bookmarkRoot.createChild("HIER", "this.pageNum = " + this.pageNum + ";\nthis.zoom = 150;", 0);
else this.bookmarkRoot.children[0].setAction("this.pageNum = " + this.pageNum + ";\nthis.zoom = 150;");
Copy link to clipboard
Copied
hey Try, are you saying that the bookmark's Mouse Up Action cannot be changed from "Run JavaScript" to "Go To Page"/fixed destination via automation?
Copy link to clipboard
Copied
The Acrobat JavaScript model does not provide functionality for setting any kind of event action to one of the built-in Action types. It can only set an event action to a script.
See the Reference
https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#id642
Copy link to clipboard
Copied
thanks, Thom. Appreciate your insight.
Copy link to clipboard
Copied
No, not with a script, but it can be automated outside of Acrobat, using a stand-alone tool, like this (paid-for) one I've developed: https://www.try67.com/tool/convert-javascript-links-to-real-links
Copy link to clipboard
Copied
You do know that this solution will only work in Acrobat Pro? And just in general it's not a good solution to modify document structure to save something like the current position.
A more general solution would use either the global object or a form field. Both of which are intended to be modified in Reader.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now