Skip to main content
Dec 28, 2018 2:05 PM UTC
Answered

event Page/Open through script?

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 is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Dec 28, 2018 3:34 PM UTC

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.

3 replies

try67
Community Expert
Community Expert
Dec 28, 2018 2:54 PM UTC

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.

Translate
Dec 28, 2018 3:17 PM UTC

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

Translate
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Dec 28, 2018 3:34 PM UTC

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.

Translate