Skip to main content
subieguy2
Inspiring
January 19, 2018
Answered

Illegal Character 1 Error

  • January 19, 2018
  • 2 replies
  • 2460 views

I am running Acrobat Pro XI on a Windows 7 computer. I have placed the following code on a button so when the user clicks it the layer

"L730-A26" will turn off.

var colorLayer = "L730-A26";

var ocgSchematicArray = this.getOCGs(this.pageNum);

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

    if (ocgSchematicArray.name == colorLayer){

        ocgSchematicArray.state = false;

        }

    }

I am getting this message:

I have run this exact code in the exact same way on another file without issue. I have deleted all the code and typed it all out (no copy and paste) to eliminate the possibility of odd characters from pasting.

Still no success. Can someone please tell me what I am doing wrong?

This topic has been closed for replies.
Correct answer Karl Heinz Kremer

I'm writing the code in Adobe Extendscript Toolkit CC. I'll try switching to the internal editor in Acrobat and see if that resolves the issue.

Thank you all for the replies!


ExtendScript is not a general purpose JavaScript editor. Use either the internal editor or a tool like NotePad++

2 replies

Bernd Alheit
Community Expert
Community Expert
January 19, 2018

What happens when you fix it?

subieguy2
subieguy2Author
Inspiring
January 19, 2018

All it does is takes me back in to allow me to edit the code

Karl Heinz  Kremer
Community Expert
Community Expert
January 19, 2018

Your code looks OK (and when I copy&paste into a new document, it does not give me the syntax error). Do you have any other scripts in your document? What happens when you try to add the script line by line, or block by block? You can start out with just the first line, then add the second line, then create the for statement, but with an empty loop body. And so on.

Is there anything past the end of the script that you've posted? Can you share the file?

subieguy2
subieguy2Author
Inspiring
January 19, 2018

I don't have any code at the document level and nothing else besides what I posted on the button. I will try to paste it in line by line as you suggested. I can't share the file due to it's content being trademarked. I will post back after I try the line by line. Thank you for your help and quick response!