Skip to main content
Participant
January 6, 2021
Answered

Use Action wizard to insert document level javascript for 'Will Close' event

  • January 6, 2021
  • 3 replies
  • 919 views

Hello! I have used JS and Action Wizard to insert document level script to turn off the form field highlights:

this.addScript("Turn Off", 'var highlightPref = app.runtimeHighlight ;
app.runtimeHighlight = false ;');

And I have the code that will reset the user's preference:

app.runtimeHighlight = highlightPref ;

I know that I can paste this into the Document Actions and it works perfectly. BUT I have many hundreds of pdfs that require this code, and I am trying unsuccessfully to find/write the code to insert the Document Will Close action using Action Wizard so I can batch process them. Can anyone help please?

This topic has been closed for replies.
Correct answer try67

You can do it using the setAction method of the Document object, like this:

this.setAction("WillClose", "app.runtimeHighlight = highlightPref;");

3 replies

Bernd Alheit
Community Expert
Community Expert
January 7, 2021

Did you test it with 2 documents?

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
January 6, 2021

You can do it using the setAction method of the Document object, like this:

this.setAction("WillClose", "app.runtimeHighlight = highlightPref;");

jax238Author
Participant
January 7, 2021

Thank you! I had tried setAction but didn't know that calling it 'WillClose' would indicate that event so couldn't get it to work. Much appreciated 😄

Joel Geraci
Community Expert
Community Expert
January 6, 2021

Are these PDF files you plan on distributing outside of your organization?