javascript doesnt work after using the "save as other" menu

New Here ,
Nov 09, 2018

Copy link to clipboard

Copied

i have a pdf file with javascript, the code works perfectly as long i´m working in the file, but when i use the "save as other/reader extended pdf/enable more tools" and i open the new file, the code no works at all.

i use the javascript console and i got this message:

ReferenceError: showCharCount is not defined

1:Field:Keystroke

i´m using this code to get the character count of a field:

in the fields from which I need to take the count, in the custom keystroke script:

showCharCount();

in a second, thirtd and fourt field (this fields are not visible to the end user, it is only for the following function):

// Document level function 

function showCharCount() { 

 

    // gets whats on the field 

    var num = AFMergeChange(event).length; 

    // show characters 

    getField("count").value = num; 

 

}

and finally in the "totalcount field":

// Set the minimum number of characters 

    var min = 1900;

event.value = ( this.getField("count").value + this.getField("count2").value ) + this.getField("count3").value + this.getField("count4").value;

// Set the value of the other text field to show how many character have been entered 

    getField("totalcount").value = event.value + " of " + min;

i got no background in programming so i really don´t know what i´m doing wrong.

P.S.

sorry, my english is not so good

Adobe Community Professional
Correct answer by Bernd Alheit | Adobe Community Professional

Define the function at document level.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

277

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

javascript doesnt work after using the "save as other" menu

New Here ,
Nov 09, 2018

Copy link to clipboard

Copied

i have a pdf file with javascript, the code works perfectly as long i´m working in the file, but when i use the "save as other/reader extended pdf/enable more tools" and i open the new file, the code no works at all.

i use the javascript console and i got this message:

ReferenceError: showCharCount is not defined

1:Field:Keystroke

i´m using this code to get the character count of a field:

in the fields from which I need to take the count, in the custom keystroke script:

showCharCount();

in a second, thirtd and fourt field (this fields are not visible to the end user, it is only for the following function):

// Document level function 

function showCharCount() { 

 

    // gets whats on the field 

    var num = AFMergeChange(event).length; 

    // show characters 

    getField("count").value = num; 

 

}

and finally in the "totalcount field":

// Set the minimum number of characters 

    var min = 1900;

event.value = ( this.getField("count").value + this.getField("count2").value ) + this.getField("count3").value + this.getField("count4").value;

// Set the value of the other text field to show how many character have been entered 

    getField("totalcount").value = event.value + " of " + min;

i got no background in programming so i really don´t know what i´m doing wrong.

P.S.

sorry, my english is not so good

Adobe Community Professional
Correct answer by Bernd Alheit | Adobe Community Professional

Define the function at document level.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

278

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
Nov 09, 2018 0
Adobe Community Professional ,
Nov 09, 2018

Copy link to clipboard

Copied

Where did you place the showCharCount function, exactly?

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...
Nov 09, 2018 0
New Here ,
Nov 12, 2018

Copy link to clipboard

Copied

i put the function in the custom keystroke script in the properties section on the field from which i need to get de count

pantalla.jpg

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...
Nov 12, 2018 0
Most Valuable Participant ,
Nov 12, 2018

Copy link to clipboard

Copied

You only placed the call to the function there. Where's the actual function definition itself?

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...
Nov 12, 2018 0
New Here ,
Nov 12, 2018

Copy link to clipboard

Copied

i put three diferent field to get the count of each field i need, this fields are not visible for the end user i just use it to get de count of each field and finally get the sum of this fields for display it on a totalcount field

this is and example of mi pdf file

pantalla2.jpg

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...
Nov 12, 2018 0
Adobe Community Professional ,
Nov 12, 2018

Copy link to clipboard

Copied

Define the function at document level.

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...
Nov 12, 2018 0
New Here ,
Nov 12, 2018

Copy link to clipboard

Copied

where can i do that?

sorry for my kind of question but a have no background in programming, this is my first try

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...
Nov 12, 2018 0
Most Valuable Participant ,
Nov 12, 2018

Copy link to clipboard

Copied

Tools - JavaScript - Document JavaScripts... Do not use the Edit All JavaScripts command for that.

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...
Nov 12, 2018 1
New Here ,
Nov 12, 2018

Copy link to clipboard

Copied

thanks that works perfectly

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...
Nov 12, 2018 0