Illegal Character 1 Error

Jan 19, 2018

Copy link to clipboard

Copied

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:

errorMessage.JPG

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?

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

TOPICS
Acrobat SDK and JavaScript, Windows

Views

541

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Illegal Character 1 Error

Jan 19, 2018

Copy link to clipboard

Copied

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:

errorMessage.JPG

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?

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

TOPICS
Acrobat SDK and JavaScript, Windows

Views

542

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 19, 2018 0
Jan 19, 2018

Copy link to clipboard

Copied

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 19, 2018 0
Jan 19, 2018

Copy link to clipboard

Copied

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!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 19, 2018 0
Jan 19, 2018

Copy link to clipboard

Copied

I get the same error on every line. So I deleted the document and started over. I created a brand new button and put the first line on it. Same error. Then same error for every line by itself. I really don't get what is going on. Again no copy and paste. Have rebooted the computer. Have recreated the file. Same error every time.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 19, 2018 0
Jan 19, 2018

Copy link to clipboard

Copied

In what application are you writing the code?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 19, 2018 1
Jan 19, 2018

Copy link to clipboard

Copied

The illegal character is probably an invisible character inserted by your editing application.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 19, 2018 2
Jan 22, 2018

Copy link to clipboard

Copied

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!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 22, 2018 0
Jan 22, 2018

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 22, 2018 2
Jan 22, 2018

Copy link to clipboard

Copied

I switched to NotePad++ and works perfectly! Thank you! I have never had an issue like this before. Grateful for the suggestions/help!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 22, 2018 0
Jan 19, 2018

Copy link to clipboard

Copied

What happens when you fix it?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 19, 2018 0
Jan 19, 2018

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 19, 2018 0