Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Illegal Character 1 Error

Engaged ,
Jan 19, 2018 Jan 19, 2018

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?

TOPICS
Acrobat SDK and JavaScript , Windows
2.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 22, 2018 Jan 22, 2018

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

Translate
Community Expert ,
Jan 19, 2018 Jan 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 19, 2018 Jan 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!

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

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.

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

In what application are you writing the code?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 22, 2018 Jan 22, 2018

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 22, 2018 Jan 22, 2018

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 22, 2018 Jan 22, 2018
LATEST

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

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

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

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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

What happens when you fix it?

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

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

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