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

Creating Bookmarks Programmatically in Acrobat v9

ye32ac92
Registered: Jun 17 2009
Posts: 22

Has this command been updated for version 9:
app.execMenuItem("NewBookmark")
When I run the below javascript code Acrobat (v9) says there is an internal error.

I'm assuming the issue is "app.execMenuItem("NewBookmark")".

function brk(splitbm)
{
// * is the authors choice for the split character, you may change it
if (splitbm.name.indexOf('*') != -1)
split(splitbm);
//split if the bookmark name has the ^ charater
if (splitbm.children != null)
for (var i=0;i< splitbm.children.length;i++)
newbrk(splitbm.children[i]);
// split all the children bookmarks of mybm
}

function split(bm)
{
var bmname=bm.name;
var splitat=bmname.indexOf('*');
// The user can change the * , remember to change the previous function as well
var topname=bmname.substring(0,splitat);
var botname=bmname.substring(splitat+1,bmname.length);
var thisdoc=bm.doc;
bm.execute();
app.execMenuItem("NewBookmark");
var thisdoc=bm.doc;
var rootlen=thisdoc.bookmarkRoot.children.length;
var newbm=thisdoc.bookmarkRoot.children[rootlen-1];
newbm.name=botname;
bm.name=topname;

// make all [childbookmarks of mybm] newbm's children
if (bm.children != null)
{
var endpos=bm.children.length;
for(a=0;a

My Product Information:
Acrobat Standard 9.0, Windows
try67
Online
Expert
Registered: Oct 30 2008
Posts: 2399
I don't have access to Acrobat 9 at the moment, but you can use this script to list all the names of the menu items. It's possible the name of this function has changed.

var menuItems = app.listMenuItems()
for( var i in menuItems)
console.println(menuItems[i] + "\n")

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

ye32ac92
Registered: Jun 17 2009
Posts: 22
I'm new to writing javascript for acrobat.
Do I just save this code inside the Javascript folder?
How do I run this code?
Thanks.
try67
Online
Expert
Registered: Oct 30 2008
Posts: 2399
Open the Console (Ctrl+J), paste it in, select it and press the Enter key on the bottom right-hand corner of your keyboard.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

ye32ac92
Registered: Jun 17 2009
Posts: 22
I guess Adobe Acrobat 9 doesn't have the JavaScript console.
I tried control+J and I checked in the Advanced menu.
Is there any way to add the console?
Thanks.
try67
Online
Expert
Registered: Oct 30 2008
Posts: 2399
Sure it has. Maybe you should check in the preferences under JavaScript if it's enabled.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com