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

What makes a form slow?

Explorer ,
Jul 10, 2017 Jul 10, 2017

Copy link to clipboard

Copied

Hi,

I have a document with 120 similar text fields + 20 dropdowns. There is mainly two simple action Javascript  + 1 format script per field. I have a button to reset all fields and it takes up to 20 seconds on a regular performing computer. The action scripts weren't absolutely essential so I've tested the document without them, but nothing changed in the time it took to reset.  Also, when I open the document, it takes quite a while for all the fields to appear.

What are the reasons that can make a document so very slow? Do I have too many fields? Are there other reasons that maybe I could correct? Thank you.

I have Adobe Acrobat Pro DC.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

882

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
community guidelines
Community Expert ,
Jul 10, 2017 Jul 10, 2017

Copy link to clipboard

Copied

You haven't posted the for so this is only a guess but I'll bet the code isn't optimized and there are a ton of string literals in it.

Add the line...

this.delay = true;

... at the top of your reset script and then.

this.delay = false;

... at the end of your reset script.

This will stop the form from redrawing the fields as it's being reset. That may give you a performance boost.

Votes

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
community guidelines
Explorer ,
Jul 10, 2017 Jul 10, 2017

Copy link to clipboard

Copied

Hi Joel,

On my reset button properties, I used the command Reset form and checked the fields I wanted to reset.

Now, to use what you suggested, I wrote a script instead of the command using this.resetForm with each of the seven parent fields.

Example :

this.delay = true;

var a= this.getField("Ville4L");

this.resetForm(a);

this.delay=false;

Is this how I'm suppose to write it? Because it did reset my form, but took even much longer!

thanks.

Votes

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
community guidelines
Community Expert ,
Jul 10, 2017 Jul 10, 2017

Copy link to clipboard

Copied

Did you want to reset the form or just a few fields?

Votes

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
community guidelines
Explorer ,
Jul 10, 2017 Jul 10, 2017

Copy link to clipboard

Copied

Initially, I had pretty much all the fields checked on the reset command. I only unchecked a few fields that were static and had no special function, in case it would help.

Votes

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
community guidelines
Community Expert ,
Jul 10, 2017 Jul 10, 2017

Copy link to clipboard

Copied

Ok - then my guess is that there's something very inefficient in the JavaScript in the fields. I can't diagnose that without the form though.

Votes

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
community guidelines
Explorer ,
Jul 10, 2017 Jul 10, 2017

Copy link to clipboard

Copied

In almost every field, I have them three script

Under action tab :

  • On mouse down :
    var f = this.getField("Ville4L.0.0"); //get the text field
    if (f.value == f.defaultValue) f.value = ""; //if field value = the default, then clear it

  • On deactivate field (?english) :
    var f = this.getField("Ville4L.0.0"); //get the text field
    if (f.value == "") f.value = f.defaultValue; //if field value = empty, then restore the default

Under format tab :

  • Custom format :
    // If field is blank, do not print this field 
    event.target.display = event.value ? display.visible : display.noPrint; 

    // If field is blank, display this text 
    if (!event.value) event.value = "Ville", event.target.textColor = color.gray;
    else
    event.value = event.value.toUpperCase(), event.target.textColor = color.black;

It all works perfectly to clear default value as we click on field, and format in capitals what is entered as we leave. The form is great for the simple task I want it to do.  But is this too heavy that it causes all the delay?

I made a test by erasing the first two scripts and leaving only the uppercase &black text color under custom format, and saw no improvement in the lag.

Thanks!

Votes

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
community guidelines
Community Expert ,
Jul 10, 2017 Jul 10, 2017

Copy link to clipboard

Copied

Try combining the two settings into one if statement. Modify the value first, then set the display property.

Votes

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
community guidelines
Explorer ,
Jul 10, 2017 Jul 10, 2017

Copy link to clipboard

Copied

Are you talking about the two scripts under the action tab? How do I do this when the first if statement is on focus and the second is on blur?

Thanks!

Votes

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
community guidelines
Community Expert ,
Jul 11, 2017 Jul 11, 2017

Copy link to clipboard

Copied

Eli-zabelle  wrote

In almost every field, I have them three script

Under action tab :

  • On mouse down :
    var f = this.getField("Ville4L.0.0"); //get the text field
    if (f.value == f.defaultValue) f.value = ""; //if field value = the default, then clear it

  • On deactivate field (?english) :
    var f = this.getField("Ville4L.0.0"); //get the text field
    if (f.value == "") f.value = f.defaultValue; //if field value = empty, then restore the default

...

At almost every field you change the field "Ville4L.0.0" ?

Votes

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
community guidelines
Explorer ,
Jul 11, 2017 Jul 11, 2017

Copy link to clipboard

Copied

LATEST

Yes. I could have worked with just event.value as I now see. Maybe I had tried at first and something didn't work quite right. I will make the changes, it might make a difference.

Votes

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
community guidelines