-
1. Re: How to speed up rendering of JavaScript annotations?
try67 Aug 12, 2010 12:14 AM (in response to DHeadrick)There could be several reasons for this:
1. Your code is not efficient. If you post it here, we could have a look at
it and see if it can be improved.
2. Your computers' hardware is not up to date.
3. Acrobat/Reader is just slow.
Another thing to consider is using some kind of progress bar to let your
users know that the action is taking place, so they don't get impatient
during those 4 seconds. There's a built-in object in Acrobat/Reader that can
do just that. Look at the Thermometer object.
-
2. Re: How to speed up rendering of JavaScript annotations?
DHeadrick Aug 12, 2010 9:14 PM (in response to try67)Hi try67,
Thanks for your reply and for the suggestion about providing the JavaScript; here is an example, starting with my initialization code:
var MyAnnotArray = new Array(30); // set up an array for the annotation objects
var i;
for(i=0; i<30; i++) MyAnnotArray[i] = this.addAnnot( {...parameters...} ); // first, I create the 30
desired annotations with "hidden: true"The following code is executed when a particular button field is clicked:
// Now lets make the annotations visible by setting hidden = false
for(i=0; i<30; i++) MyAnnotArray[i].hidden = false; // This causes all 30 annotations to be displayed
Please forgive any typos above. Again, it takes 4 seconds for the 30 annotations to be displayed. I would expect each of the 30 annotations to sequentially appear as its hidden property is changed to false. However, nothing appears for 4 seconds, then all 30 annotations simultaneously appear.
This slowness has been evident on all 6 computers I've tested, and is evident with both Acrobat (on 2 computers) and with Adobe Reader (on the other 4 computers). Acrobat is version 9 and Adobe Reader is both 8 and 9, depending on the particular computer.
Thanks for the suggestion about the Thermometer object, I'll add it to the for loop that changes the 30 hidden properties to false to at least give the user assurance that *something* is going on.
In the meantime, if you have any further thoughts on the general issue, I'm all ears. I don't necessarily think it's a speed issue of *changing* the annotation properties, it seems to be a speed issue of *rendering* (displaying) the revised annotations. I think perhaps the 30 .hidden properties are being changed rapidly but, for unknown reasons, the display isn't refreshed until the hidden properties have been changed for all 30 objects -- hence, the delay. Perhaps the rendering isn't occurring until I exit the button-triggered JavaScript that changes the .hidden property. This seems somewhat logical -- the JavaScript scheduler could be saying "OK, he's done changing all of the properties and is ready to exit the button-triggered JavaScript, now would be a good time to do the rendering of all of the previous changes".
Thanks again for your insights.
Dave
-
3. Re: How to speed up rendering of JavaScript annotations?
try67 Aug 13, 2010 2:12 AM (in response to DHeadrick)The code is pretty straight-forward. I don't see any way of improving it,
really.
I'm afraid I don't have any other ideas for the moment.
Only this... Try disabling this property:
Preferences > Page Display > Rendering pane > Use 2D graphics acceleration
-
4. Re: How to speed up rendering of JavaScript annotations?
DHeadrick Aug 13, 2010 9:22 AM (in response to try67)Hi again,
Well, it's hard to believe but the inclusion of the Thermometer object *greatly* sped up *all* rendering, even rendering where I'm not using the Thermometer object. Since I never really understood the basis of the original problem, it's hard to theorize why Thermometer would help speed up everything, but it does. Both the initialization (where I'm using Thermometer) and all button-triggered JavaScripts (where I'm not using Thermometer) are now much faster.
So, thank you very much for the tip! I'm back in business.
Dave
P.S. I first tried changing the 2D accelerator preference but that didn't make a difference, so I restored the original preference.
-
5. Re: How to speed up rendering of JavaScript annotations?
GKaiseril Aug 13, 2010 11:18 AM (in response to DHeadrick)It probably has to due with the redrawing of the objects being turned off while the thermometer is displayed.
You could even try 'this.calculate = false;" at the start of the script and 'this.calculate = true;' at the end of the script to turn off the auto calculate of Acrobat.
-
6. Re: How to speed up rendering of JavaScript annotations?
DHeadrick Aug 13, 2010 11:07 PM (in response to GKaiseril)Hi,
Thanks for the tip about setting this.calculate = false. Although my post focused only on annotations, I do have a number of text fields that I use. Since I don't do any calculations on the contents of any of the text fields, it only makes sense to set this.calculate = false. I don't bother setting it back true at the end of the script, presumably that won't have any "unintended consequences" with something else.
Every bit helps performance-wise, thanks again.
Dave
-
7. Re: How to speed up rendering of JavaScript annotations?
try67 Aug 16, 2010 1:33 AM (in response to DHeadrick)Glad to hear it works better. I think that the fact that the thermometer
itself needs to update causes the visual rendering engine of Acrobat to
update the entire application, thus displaying the annotations. Odd, but as
long as it works...
I don't recommend setting this.calculate to false. If you have no
calculation in your file it doesn't matter anyway, and if one day you would
want to add them, you won't understand why it's not working.



