Skip to main content
May 17, 2017
Answered

Javascript syntax error

  • May 17, 2017
  • 1 reply
  • 501 views

Hi,

There is an issue with my javascript but having trouble identifying it.  The script is supposed to find and highlight words I want to react,  but must skip over anything that is already marked with overlaytext.

This is what I have done so far ...

- Using the "Actions" feature in Adobe I use the "Search & Remove" dialog to search for words I want to redact.

- I then run the below JavaScript to highlight the words found in yellow

var colHilite = ["CMYK",0,0, 1, 0]; // yellow

var oDoc = event.target;

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

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

{

                            

if (aAnnts.type == "Redact") {                              

  if ((overlayText != "Overlay1") || (overlayText != "Overlay2")); // This line seems to be causing issues, Skip highlight over words that have been marked with overlay

                                }

    {

    aAnnts.type = "Highlight";

    aAnnts.strokeColor = colHilite;

    }

}

Thanks in advance for your help !

Karl Heinz KremerKarl Heinz Kremer

This topic has been closed for replies.
Correct answer try67

That line indeed has multiple problems with it.

First of all, remove the semi-colon after it.

Also, you didn't define a variable called "overlayText". It's a property of the Annotation object, so access it like this:

aAnnts.overlayText

And finally, your condition will always be true... You probably mean if the overlay text is not "Overlay1" AND not "Overlay2", not OR.

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
May 17, 2017

That line indeed has multiple problems with it.

First of all, remove the semi-colon after it.

Also, you didn't define a variable called "overlayText". It's a property of the Annotation object, so access it like this:

aAnnts.overlayText

And finally, your condition will always be true... You probably mean if the overlay text is not "Overlay1" AND not "Overlay2", not OR.

May 17, 2017

Thank You ! try67​ .  Your suggestions helped fix the issue