I am currently using Adobe Acrobat 9.0 Professional. I have a large 1400+ page scanned document with several bookmarks in it. I need to create a listing of the bookmarks. I'm using the standard list all bookmarks sequence which I've copied here for reference:
/* List all Bookmarks */ /* Recursively work through bookmark tree */ function PrintBookmarks(bm, nLevel) { if (nLevel != 0) { // don't print the root bmReport.absIndent=bmTab*(nLevel-1); bmReport.writeText(util.printf("%s",bm.name)); } if (bm.children != null) for (var i = 0; i < bm.children.length; i++) PrintBookmarks(bm.children[i], nLevel + 1); } // Set up the parameters to write a report bmTab = 20; bmReport = new Report(); bmReport.size = 2 // Large font size for title bmReport.writeText(this.title); bmReport.writeText(" "); // Skip a line bmReport.size = 1.5; // Slightly smaller for heading bmReport.writeText("Listing of Bookmarks"); bmReport.writeText(" "); bmReport.size = 1; // Default size for everything else PrintBookmarks(this.bookmarkRoot, 0); // Start moving through bookmarks // Make it global so the object will be "remembered" after batch is done. global.bmRep = bmReport; // Make global for next step reportDoc = global.bmRep.open("Listing of Bookmarks"); console.println("Executed Report.open"); reportDoc.info.title = "Bookmark Listings"; reportDoc.info.Author = "A. C. Robat";
The problem I'm having is that the bookmarking code is only producing the first page of bookmarks and then stops. It gets to the end of the first page and then just stops. Is there some change to the code I can make to force it to move on and print the rest of the bookmarks?
Specifically, the problem is that it will not create a new page when the old page overflows. You have to manually call the "report.pageBreak()" function. Of coures, from the script there is no direct way of knowing when the page overflows, so you have to guess.
To do this, add a counter to the loop. Make it a global variable, i.e. declare it outside the "PrintBookmarks" function. Then increment it after every "bmReport.writeText()" call. At the bottom of the function add an "if" to test the number of lines printed, if its greater that the pageMax then reset the counter and call the "report.pageBreak()" function.
The question of coures is, what is "pageMax". To find out count the lines on the print out you already got for the original script.
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script