Skip to main content
Participant
December 2, 2024
Question

Mysterious Errors with Acrobat Pro Printing Script That Uses setTimeOut (Script Attached)

  • December 2, 2024
  • 1 reply
  • 1003 views

I'm trying to develop code that, with one click on a form button, (a) temporarily displays COPY over a select page then (b) prints predefined pages in a predefined order to the user's default printer. However, when the code runs (after I click any form button related to the code), nothing happens except for this error message in console:

 

SyntaxError: missing ] after element list
2:Doc:Exec

 

I'm pretty sure I'm not actually missing a bracket. The code validates as compliant JavaScript. I even removed the printRange properties (whose parameters require brackets, which is my only use of brackets in the code) and am still getting the error. 

 

Does anyone have any idea what could be causing the syntax error? Could setTimeOut be causing it?

 

I'm using Adobe Acrobat Pro Continuous Release for Mac, New Acrobat UI. The code is a document-level script.

 

Thanks!

 

<text attachment removed per op -kglad>

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
December 2, 2024

Why the function definitions in each setTimeOut command? The code that is used there needs to be a string, which is evaluated as code and executed. So the first one should be, for example:

 app.setTimeOut("printJob(\"CourtOriginal\");", 1000);

 

try67
Community Expert
Community Expert
December 2, 2024

Also, you should use a variable to receive the return value of the setTimeOut calls, even if you do nothing with it later on. I've seen cases where not doing that can cause it to malfunction. So the line above should actually be:

 

 

var timeoutObj1 = app.setTimeOut("printJob(\"CourtOriginal\");", 1000);

 

try67
Community Expert
Community Expert
December 2, 2024

I'm not getting the error message you mention from the code you shared.  It seems to come from somewhere else, based on the error message itself. Is there other code in the file?
Also, are you aware that the printShop_initialization method will cause an error if the file is opened in Reader?