Link to home
Start Free TrialLog in
Avatar of scsoil
scsoil

asked on

Search and Bookmark Javascript for Acrobat

I need a Javascript to wok in Acrobat that will search through a searchable pdf documents for specific phrases and create a bookmark with the phrases name when if finds them.

This is a static lists of phrases eg. "PATIENT PROFILE", "COLONOSCOPY" ...

I will need to do this in a folder of approximately 1200 documents.
ASKER CERTIFIED SOLUTION
Avatar of mohan_sekar
mohan_sekar
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I was able to do this with just java script.  I also create a new file for each page and give it the name of my bookmark.


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) {                                                                          
                          this.extractPages({nStart:i, cPath: PageText + ".pdf"});
                              root.createChild(PageText,"this.pageNum=" + i, i);
                                     
                              FoundSASID = 0;
                        }
                        if (FoundSASID==0) {
                              PageText = "";
                        }

                        }
            }
    }