Click to See Complete Forum and Search --> : Bookmarks in Acrobat


eichatcyber
07-23-2003, 03:40 PM
I am working with Adobe Acrobat to modify pdf's and I have a batch process to do a lot at one time. I can insert my bookmarks into the pdf and can either leave them all expanded or collapsed but I would like it to collapse all of them except the top level of bookmarks. Here is my code can anyone help

var cPath = this.path;
if(typeof global.bookmarkToggleState=="undefined")
{
global.bookmarkToggleState = new Object();
global.bookmarkToggleState[cPath]=false;
}

// Toggle the known state of the bookmarks for the active document
if(global.bookmarkToggleState[cPath]==false)
{
global.bookmarkToggleState[cPath]=false;
}
else
{
global.bookmarkToggleState[cPath]=false;
}

// Perform the toggle
ToggleBookmark(this.bookmarkRoot, 0, global.bookmarkToggleState[cPath]);

// Collapse a bookmark and all its children.
function ToggleBookmark(bm, nLevel, bOpen)
{
bm.open = bOpen;
if (bm.children != null)
{
for (var i = 0; i < bm.children.length; i++)
{
ToggleBookmark(bm.children[i], nLevel + 1, bOpen);
}
}
}