Copy link to clipboard
Copied
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.
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thanks, your solution works, though I'm still wondering what's some practical way to use the API's event Page/Open.
Copy link to clipboard
Copied
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.