2 Replies Latest reply on Mar 21, 2012 4:47 AM by try67

    Can you help add a split page operation to my batch script?

    AcroJava

      Below is my batch script to create a bookmark on each page of a pdf.  It takes all the text from the current page and adds it to a variable then checks the variable for the string "SASID:"    It then takes the 10 digits following the "SASID:" string and creates a book mark with the 10 digits as the name.   I am looking to use the extract page method to extract each page to a new file.  Each new file should have the name of the string on that page.  So.  I think I need to add something like this.extractPages({nStart: i,cPath : filename + i + ".pdf"})   Either directly  before or after this line root.createChild(PageText,"this.pageNum=" + i, i); and the filename should be the variable that holds the 10 digit string.  I do beleive "newWord" contains the 10 digit number. Thank you!

       

       

       

       

       

       

      var root = this.bookmarkRoot;
      var RegularExpression  =  new RegExp(/\n|\r|\t|\s/);

      for (var i = 0; i < this.numPages; i++)
          {
              numWords = this.getPageNumWords(i);
              var PageText = "";
      var FoundSASID = 0;
             
      for (var j = 0; j < numWords; j++) {
                  var word = this.getPageNthWord(i,j,false);
      PageText += word;

      var strMatches = PageText.match('SASID:');
                   if (strMatches != null) {
      // Found text SASID: So reset the PageText to nothing and set the FOundSASID to 1
      FoundSASID = 1;
      PageText = "";
      }

      var newWord = PageText.match(RegularExpression);
      var foundSpace = PageText.match(' ');
      if (newWord != null || foundSpace != null) {
      if (FoundSASID==1) {
      root.createChild(PageText,"this.pageNum=" + i, i);
      FoundSASID = 0;
      }
      if (FoundSASID==0) {
      PageText = "";
      }

      }
                  }
          }