These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Bookmarking using javascript

thulasiramts
Registered: Oct 11 2007
Posts: 2

I am having bulk of books in a folder to be bookmarked (Standarad Bookmarks). I have a javascript code to create bookmarks and run using batch processing. What are the standard procedures to execute a js without batch process?

My Product Information:
Acrobat Pro 7.0.0, Windows
pddesigner
Registered: Jul 9 2006
Posts: 858
This example implements a simple search of the bookmarks. If successful, the action associated with the bookmark is executed.

// Document-level or folder-level JavaScript.
function searchBookmarks(bkm, nLevel, bkmName)
{
if ( bkm.name == bkmName ) return bkm;
if (bkm.children != null) {
for (var i = 0; i < bkm.children.length; i++)
{
var bkMark = searchBookmarks(
bkm.children[i], nLevel + 1, bkmName);
if ( bkMark != null ) break;
}
return bkMark;
}
return null;
}
// Redefine this function for a more sophisticated compare.
function bmkCompare( name1, name2 )
{
return ( name1 == name2 );
}

The following code initiates the search. This code could be executed as field-level JavaScript or be executed as a menu action.

var bkmName = app.response({
cQuestion: "Enter the name of the bookmark to find",
cTitle: "Bookmark Search and Execute"
});
if ( bkmName != null ) {
var bkm = searchBookmarks(this.bookmarkRoot, 0, bkmName );
if ( bkm != null ) bkm.execute();
else app.alert("Bookmark not found");
}

Create a bookmark at the top of the bookmark panel that takes you to the next page in the document.

this.bookmarkRoot.createChild("Next Page", "this.pageNum++");

Attach an action to the topmost bookmark.

var bm = bookmarkRoot.children[0]
bm.setAction("app.beep(0);");

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There are 2 ways to execute an Automation JavaScript outside of a batch process.

1. Menu Item - You can add menu items to the Acrobat user interface with the "app.addMenuItem()" fucntion

2. Toolbar Buttons - Toolbar buttons are added to the "Add-Ins" toolbar with the "app.addToolButton()" function. This one is my favorite. Toolbar buttons are more visible to the user than menu items and they can have a nice icon on them. Here's a link to a 3rd party tool for creating toolbar buttons with JavaScript.

[url=http://www.windjack.com/products/acrobuttons.php]http://www.windjack.com/products/acrobuttons.php[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script