4 Replies Latest reply on Aug 17, 2009 5:12 PM by Jo_2005

    Listing Bookmark Script Align Page Numbers to Right

    Jo_2005 Level 1

      Hello,

       

      I have a script which will list Bookmark Names and then the Page Number after the bookmark as follows:

       

      Bill Smith  Page#1

      Jeffrey Jones  Page#5

      Christopher James  Page#8

       

      What I would like the script to achieve is to list the bookmarks and then align the Page numbers to the right side of the pdf instead of jumbled together.

       

      Can anyone please advise if it is possible to do this in javascript?

       

      The existing code is as follows:

      /* 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);
      bm.execute();
                  bmReport.writeText(" "+bm.name +" 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);

       

      Any help will be much appreciated

       

        • 1. Re: Listing Bookmark Script Align Page Numbers to Right
          try67 MVP & Adobe Community Professional

          The Report object is badly flawed. Beside the known page break bug in version 9 there are many other issues, such as the alignment issue.

          The best solution I've found for it was to place the page numbers on a new line and then align them with indent and outdent.

          • 2. Re: Listing Bookmark Script Align Page Numbers to Right
            Jo_2005 Level 1

            Thank you very much for your help.

             

            I have modified the script to have the bookmarks and page numbers on separate lines, however the indent does not go further than the middle of the page on the seconde line for the page numbers, no matter how much the indent is modifed  (I am also using version 8 of Adobe).

             

            Can you please advise how to get the indent to increment past the middle of the page to the right side of the page?

             

            The script which has been modified is as follows:

             

             

             

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

            • 3. Re: Listing Bookmark Script Align Page Numbers to Right
              try67 MVP & Adobe Community Professional

              It's just another "feature" of the Report object, I'm afraid...

              • 4. Re: Listing Bookmark Script Align Page Numbers to Right
                Jo_2005 Level 1

                Thank you very much for your help.

                 

                I was hoping to achieve a "Table of Contents" from the Bookmark Script and being able to align the page numbers to the right.

                 

                By modifying the script as you suggested has brought this closer to what I wanted to achieve, its a shame about the indent not going further than the middle of the page though.