• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

event Page/Open through script?

New Here ,
Dec 28, 2018 Dec 28, 2018

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.

TOPICS
Acrobat SDK and JavaScript

Views

433

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 28, 2018 Dec 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.

Likes

Translate

Translate
Community Expert ,
Dec 28, 2018 Dec 28, 2018

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 28, 2018 Dec 28, 2018

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2018 Dec 28, 2018

Copy link to clipboard

Copied

LATEST

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines