2 Replies Latest reply on Aug 23, 2012 3:49 PM by Jo_2005

    Set the page destination of bookmarks

    Jo_2005 Level 1

      The script I have will search a document (containing time sheets) looking for the pages which do not include the text "employee signature"

       

      The pages that do not contain the text "employee signature" are reported back to the console (this part of the script works)

       

      The next part of the script is to create bookmarks for those pages which do not have the text "employee signature" and set the page destination to that specific page.

       

      The script will create the bookmarks, but does not set the page destination to the correct page.

       

      I have tried revising the bookmark set destination with javascript in different ways but cannot get it to work.

       

      Examples as follows:

       

      this.bookmarkRoot.createChild("Next Page", this.pageNum = i+1); 

       

      Book mark Set action  properties- Javascript for bookmark shows the page number only eg 61

       

      this.bookmarkRoot.createChild("Next Page", "this.pageNum = i+1"); 

       

      Book mark set action - javascript for bookmark shows the scripting itself and does not go to the page number eg this.pageNum = i+1

       

      The complete script shown below:

       

      var ckWords; // word pair to test

      var bFound = false; // logical status of found words

      // loop through pages

      for (var i = 0; i < this.numPages; i++ ) {

         bFound = false; // set found flag to false

         numWords = this.getPageNumWords(i); // number of words on page

         // loop through the words on page

         for (var j = 0; j < numWords-1; j++) {

            // get word pair to test

            ckWords = this.getPageNthWord(i, j) + ' ' + this.getPageNthWord(i, j + 1); // test words

            // check to see if word pair is 'Employee Signature' string is present

            if ( ckWords == "Employee Signature") {

               bFound = true; // indicate found logical value

               break; // no need to further test for this page

            } // end Employee Signature

         } // end word loop

         // test to see if words not found

         if(bFound == false) {

               console.println('Pages that do not include an employee signature: ' + (i + 1) +' ');

                 this.bookmarkRoot.createChild("Next Page", this.pageNum = i+1);

          } // end not found on page  

      } // end page loop

       

      If anyone can please help me modify the script to set the page destination for the bookmarks I will be most grateful.

        • 1. Re: Set the page destination of bookmarks
          George_Johnson MVP & Adobe Community Professional

          Try this:

           

          this.bookmarkRoot.createChild("Next Page", "this.pageNum = " + (i+1)); 

          1 person found this helpful
          • 2. Re: Set the page destination of bookmarks
            Jo_2005 Level 1

            Thank you George, the script will now sucessfully create a bookmark for the pages that do not contain the string "Employee Signature"

             

            The document has existing bookmarks for each page (time sheet) and the new bookmarks created with the script need to be placed underneath the existing bookmarks.

             

            The script places the bookmarks at the topmost part of the bookmark tree.

             

            I have modified the script further to go to the last bookmark before creating the new employee signature bookmark but the follow console error is reported back:

             

            this.bookmarkRoot.children[i].children.createChild is not a function

            44:Console:Exec

            TypeError:

             

            Can you please take a look at the script and advise where I am going wrong?

             

            // Create Employee Signature Bookmarks     

            for (var i=0; i < this.bookmarkRoot.children.length; i++)

             

            {

             

                 this.bookmarkRoot.children[i].execute();

             

                 var nStart = this.pageNum;

             

                 var nEnd = nStart;

             

                  var bmname = this.bookmarkRoot.children[i].name;

             

                 if( this.bookmarkRoot.children[i].children)

             

                 {// Only look for the end if sub-bookmarks exist

             

                    var nLastSub = this.bookmarkRoot.children[i].children.length-1;

             

                    this.bookmarkRoot.children[i].children[nLastSub].execute();

             

                    nEnd = this.pageNum;

             

                }

            var ckWords; // word pair to test

            var bFound = false; // logical status of found words

            // loop through pages

            for (var i = 0; i < this.numPages; i++ ) {

               bFound = false; // set found flag to false

               numWords = this.getPageNumWords(i); // number of words on page

               // loop through the words on page

               for (var j = 0; j < numWords-1; j++) {

                  // get word pair to test

                  ckWords = this.getPageNthWord(i, j) + ' ' + this.getPageNthWord(i, j + 1); // test words

                  // check to see if word pair is 'Employee Signature' string is present

                  if ( ckWords == "Employee Signature") {

                     bFound = true; // indicate found logical value

                     break; // no need to further test for this page

                  } // end Employee Signature

               } // end word loop

               // test to see if words not found

               if(bFound == false) {

                     console.println('Pages that do not include an employee signature: ' + (i + 1) +' ');

                      this.bookmarkRoot.children[i].children.createChild("Employee Signature ", "this.pageNum = " + (i+1));

             

                } // end not found on page  

            } // end page loop

             

            }

             

            Thanks, George much appreciated