Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all articles
Browse latest Browse all 12130

Extract Bookmarks and page numbers

$
0
0

I am looking for a either a piece of ActionScript or VBA to get all bookmark names and page numbers from a selected PDF and either export as a CSV (ActionScript) or dump into Excel (VBA option).  Any ideas?

 

I found the code below that works to make a PDF containing the bookmark names and page numbers, but was looking for something cleaner. Thanks.

_____________________________

 

* List all Bookmarks first then Page Numbers */

/* Recursively work through bookmark tree  */

function PrintBookmarks(bm, nLevel)

{

    if (nLevel != 0) { // don't print the root

       bmReport.absIndent=bmTab*(nLevel-1);

bm.execute();

            bmReport.writeText(" "+bm.name);

bmReport.absIndent=(580);
bmReport.writeText(" Page "+(bm.doc.pageNum +1));

          }       
    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);


Viewing all articles
Browse latest Browse all 12130

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>