6 Replies Latest reply on Apr 27, 2015 8:38 PM by robertb91778563

    Extract Bookmarks and page numbers

    robertb91778563

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