5 Replies Latest reply on Dec 20, 2017 1:52 PM by Thom Parker

    Script to Find, Highlight and do replace annotation

    agustinm25021679 Level 1



      Everyday I have to review several pdf documents, search for specific words that are not allowed, mistakes, typos, etc, and do comment annotations, either highlights, text boxes, insert text at cursor or replace.


      I have found useful tool sequence that finds specific words in the pdf and highlights them, this is very helpful already but I want to take it to the next step.


      I am trying to find a script that instead of doing the highlight annotation, it does the replace annotation and gives an alternate option to not permitted words, for example:


      Lets say that the word "colour" is not permitted, it should say "color" instead. In the sequence I already have I input the "colour" in the list of words that should be highlighted, and after running the sequence the pdf would look like this:


      "The colour is blue"


      what I want is, instead of highlighting it, it should do the replace annotation and suggest the word "color" that I should've already inputted as a replacement everytime "colour" is found. The same for any given amount of word (I have a big list)


      Here is the current script I am using to find and highlight:


      //         NOTE: This JavaScript code is intended soley for use in an

      //               Action (Batch Sequence)script.  It will not operate

      //               within a document/form field script or as a folder level script.

      //               Further, this script require that the document be first marked up

      //               with redaction annotations.


      //   This script is the second step in a two step process for marking words in a

      //   PDF with the highlight annotation. 


      //   Step #1: Use the Search for words to Redact tool to mark words in the

      //            PDF with the Redact Annotation

      //   Step #2: Use the following script to convert all Redact Annots into

      //            Highlight Annotataions.


      // Highlight Color

      var colHilite = color.yellow;

      var oDoc = event.target;


      var aAnnts = oDoc.getAnnots({sortBy:"Author"});

      for(var i=0;i<aAnnts.length;i++)


         if(aAnnts[i].type == "Redact")


            aAnnts[i].type = "Highlight";

            aAnnts[i].strokeColor = colHilite;




      Here is the link of instructions: