I've got a 9000+ page pdf files that contains thousands of scanned documents. The person who put the file together bookmarked the first page of each document but created no other TOC or other reference. I've been asked to figure out a way to generate a TOC from the bookmarks. I've figured out how to export the bookmarks (using a batch sequence file) but I haven't yet been successful figuring out how to export the page numbers with it. I'm not a programmer and I don't begin to pretend to know how to code in javascript (so don't laugh too much at the following). I was hoping to modify the "List All Bookmarks" sequence (which i believe came with Acrobat 7) which looked like this:
/* 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); } bmTab = 20; bmReport = new Report(); bmReport.size = 2; bmReport.writeText(this.title); bmReport.writeText(" "); bmReport.size = 1.5; bmReport.writeText("Listing of Bookmarks"); bmReport.writeText(" "); bmReport.size = 1; PrintBookmarks(this.bookmarkRoot, 0); global.bmRep = bmReport; // make global global.wrtDoc = app.setInterval( 'try {' +' reportDoc = global.bmRep.open("Listing of Bookmarks");' +' console.println("Executed Report.open");' +' app.clearInterval(global.wrtDoc);' +' delete global.wrtDoc;' +' console.println("Executed App.clearInterval");' +' reportDoc.info.title = "Bookmark Listings";' +' reportDoc.info.Author = "List Bookmark Sequence";' +'} catch (e) {console.println("Waiting...: " + e);}' , 100);
To something like this:
/* 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)); bmReport.writeText(util.printf("%s", bm.action.page)); } if (bm.children != null) for (var i = 0; i < bm.children.length; i++) PrintBookmarks(bm.children[i], nLevel + 1); } bmTab = 20; bmReport = new Report(); bmReport.size = 2; bmReport.writeText(this.title); bmReport.writeText(" "); bmReport.size = 1.5; bmReport.writeText("Listing of Bookmarks"); bmReport.writeText(" "); bmReport.size = 1; PrintBookmarks(this.bookmarkRoot, 0); global.bmRep = bmReport; // make global global.wrtDoc = app.setInterval( 'try {' +' reportDoc = global.bmRep.open("Listing of Bookmarks");' +' console.println("Executed Report.open");' +' app.clearInterval(global.wrtDoc);' +' delete global.wrtDoc;' +' console.println("Executed App.clearInterval");' +' reportDoc.info.title = "Bookmark Listings";' +' reportDoc.info.Author = "List Bookmark Sequence";' +'} catch (e) {console.println("Waiting...: " + e);}' , 100);
Unfortunately (and probably obviously to anyone who actually knows javascript coding) I can't simply add:
bmReport.writeText(util.printf("%s", bm.action.page));
Can someone give me a hand with what I would need to add or change in the "List All Bookmarks" batch sequence to have it export the page number of the bookmark as well? Thanks for your help!
Not sure where you got the action.page but there is no "action" property in Acrobat JS. While I am not a "real" programmer, I do play one on the internet-LOL. I tried my hand at fixing the script below (with a little help from my JS guru partner)- try it out and see if it will work for you. It was a good exercise for me and I hope it works for you.
Hope this helps,
Dimitri
WindJack Solutions
www.windjack.com
www.pdfscripting.com
Dimitri Munkirs
WindJack Solutions
pdfscripting.com