Skip to main content
December 28, 2018
Answered

event Page/Open through script?

  • December 28, 2018
  • 1 reply
  • 1114 views

I'd like to run a script dynamically at every page, without executing a menu item or running the console at every page change, and not manually as described in this tutorial

https://acrobatusers.com/tutorials/entering-page-actions

I've tried at the folder-level and document-level script

if (event.type === 'Page' && event.name === 'Open') {

    app.alert('test')

}

Nothing happened when pages changed.

This topic has been closed for replies.
Correct answer try67

There isn't one. There's no "event handler" that will execute each time you open any page. All events are tied to a specific page, field, bookmark, etc. The only generic events are at the doc-level, when you open it, close it, save it, print it, etc.

1 reply

try67
Community Expert
Community Expert
December 28, 2018

You can't do it like that. You can use a script to apply the same code to each page's Open event, though.

The code to use would be:

for (var i=0; i<this.numPages; i++) {

    this.setPageAction(i, "Open", "app.alert('test');");

}

Run this code once from the JS Console and all the pages will be edited.

December 28, 2018

Thanks, your solution works, though I'm still wondering what's some practical way to use the API's event Page/Open.

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
December 28, 2018

There isn't one. There's no "event handler" that will execute each time you open any page. All events are tied to a specific page, field, bookmark, etc. The only generic events are at the doc-level, when you open it, close it, save it, print it, etc.