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

Error in Acrobat JavaScript Console

Participant ,
Oct 14, 2016 Oct 14, 2016

Hi, i have adobe pro xi & foxit phantom 6 in my pc. if i run bellow code in foxit JavaScript Console, working perfectly but if run same code in Acrobat JavaScript Console, giving error. can u pls help me find out the issue ??. thanks..

for (var i = 0; i < numFields; i++) {

var f = getField(getNthFieldName(i));

f.comb = false;

f.charLimit = false;

f.doNotSpellCheck = false;

f.doNotScroll = false;

TOPICS
Acrobat SDK and JavaScript
4.6K
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 ,
Oct 14, 2016 Oct 14, 2016

There is a closing "}" missing. If that's not the problem, then what exactly is the error message you are getting?

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 ,
Oct 14, 2016 Oct 14, 2016

One more thing: The properties you want to set would only be valid for text fields, so if you have any other field type in your document, then that is very likely the reason for the error message.

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
Participant ,
Oct 14, 2016 Oct 14, 2016

hi, i have add closing "}" & got bellow error. also my form has check boxes & radio buttons. thaks..

SyntaxError: syntax error

1:Console:Exec

undefined

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
LEGEND ,
Oct 14, 2016 Oct 14, 2016

It would be helpful if you were to post the entire error message. Unfortunately JavaScript is an interpreted language and comes to a halt at the first error encountered. This means you will debugging one error at a 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
Participant ,
Oct 14, 2016 Oct 14, 2016

hi, i have add closing "}" & got bellow error. also my form has check boxes & radio buttons. thaks..

SyntaxError: syntax error

1:Console:Exec

undefined

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
LEGEND ,
Oct 14, 2016 Oct 14, 2016

You may need to share your form or an example with the same issue for others to diagnose the problem.

Do you have fields that are other than text fields? If so, then you need to exclude them from being processed by testing the "type" property.

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
Participant ,
Oct 14, 2016 Oct 14, 2016

hi,my form has check boxes & radio buttons. thaks..

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
LEGEND ,
Oct 14, 2016 Oct 14, 2016

You then need to test the field's "type" property and only process the "text" type. Also the "charLimit" property requires an integer value and not a logical value.

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 ,
Oct 14, 2016 Oct 14, 2016

In that case, there is something else wrong. When I run your script (as typed, just with the "}" added at the end), I get the following when the script encounters a non-text field:

InvalidSetError: Set not possible, invalid or unknown.

Field.comb:3:Console undefined:Exec

You are getting a syntax error, which you should not based on your script.

Do you know how to execute a multi-line script in the console window? Take a look here for a tutorial about how to use the console and how to execute code: https://acrobatusers.com/tutorials/javascript_console

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
LEGEND ,
Oct 14, 2016 Oct 14, 2016

Also, Phantom doesn't report errors like Acrobat does, so it very well didn't actually work there either.

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
Participant ,
Oct 14, 2016 Oct 14, 2016

hi, i have manage to work bellow code..

for (var i = 0; i < this.numFields; i++) {

var fNm = this.getNthFieldName(i);

var f = this.getField(fNm);

if (f.type == "text") {

f.doNotSpellCheck = false;

f.doNotScroll = false;

}

}

now i want add bellow two codes into same script.

f.comb = false;

f.charLimit = false;

my problem is if i add that two lines into above script, it's giving bellow error. pls help me. thanks..

RangeError: Invalid argument value.

Field.charLimit:15:Console undefined:Exec

false

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 ,
Oct 15, 2016 Oct 15, 2016

charLimit is an numerical value

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
Participant ,
Oct 15, 2016 Oct 15, 2016

hi, actually what i want to do is, in my PDF form any text field has bellow options selected then i want to remove that selection. can  u pls help me. thanks..

limit number of characters

comb of characters

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 ,
Oct 15, 2016 Oct 15, 2016

I think there's a bug in Acrobat that prevents setting these properties. I've also encountered it a couple of times in the past...

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
Participant ,
Oct 15, 2016 Oct 15, 2016

hi, so as per u bellow code is correct ??

for (var i = 0; i < this.numFields; i++) {

var fNm = this.getNthFieldName(i);

var f = this.getField(fNm);

if (f.type == "text") {

f.doNotSpellCheck = false;

f.doNotScroll = false;

f.charLimit = false;

f.comb = false;

}

}

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 ,
Oct 15, 2016 Oct 15, 2016

Almost. Try this line:

f.charLimit = 0;

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
Participant ,
Oct 15, 2016 Oct 15, 2016

sorry no luck. got bellow error.

RangeError: Invalid argument value.

Field.charLimit:13:Console undefined:Exec

false

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 ,
Oct 15, 2016 Oct 15, 2016

As I said, I believe it's a bug. You should report it here: Feature Request/Bug Report Form

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
Participant ,
Oct 15, 2016 Oct 15, 2016

ok thanks.

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
LEGEND ,
Oct 15, 2016 Oct 15, 2016
LATEST

Have you tried any other integer value than zero?

I have found any integer between 1 and  2,147,483,647 works without error. Certainly any number 1,000,000,000 or larger should be large enough to make the field appear to hold an unlimited number of characters.

Your script could read:

var f; // for field object;

for (var i = 0; i < this.numFields; i++)

{

f = this.getField(this.getNthFieldName(i));

if(f.type == "text")

{

  f.comb = false;

  f.charLimit = 2147483647;

  f.doNotSpellCheck = false;

  f.doNotScroll = false;

} // end type text;

} // end numFields;

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