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

I have a pdf page with 6 buttons. How do I change the action using javascript?

Guest
Nov 10, 2016 Nov 10, 2016

I have a page with 6 buttons.  How do I change the action using javascript?

TOPICS
Acrobat SDK and JavaScript , Windows
508
Translate
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 ,
Nov 10, 2016 Nov 10, 2016

Something like this...

this.getField("BUTTONNAME").setAction(trigger, code);

The trigger is a string and can be any one of...

MouseUp

MouseDown

MouseEnter

MouseExit

OnFocus

OnBlur

Keystroke

Validate

Calculate

Format

code is also a string but it's the JavaScript that gets executed this this...

"app.beep(0);"

Translate
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
Guest
Nov 10, 2016 Nov 10, 2016

Thanks.  Can you also tell me how to set the action to open a bookmark?

Translate
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 ,
Nov 10, 2016 Nov 10, 2016

What do you mean by "open a bookmark", exactly?

Translate
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 ,
Nov 10, 2016 Nov 10, 2016

There are examples of finding and executing bookmarks all over this forum. Just find the one that worksfor you and put it in the JavaScript "code" string in my example above.

Translate
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
Guest
Nov 10, 2016 Nov 10, 2016

I am looking to open a bookmark with the code below instead of going to a page number.

var f = this.getField("Button1");  f.setAction("MouseUp", "this.pageNum = 1";

Translate
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 ,
Nov 10, 2016 Nov 10, 2016

You'll need to iterate over the entire bookmark tree, looking for that bookmark's name, and when you find it you can use the execute method to run the action associated with it.

Translate
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
LEGEND ,
Nov 10, 2016 Nov 10, 2016
LATEST

See bookmark.execute() method in the JavaScript API Reference for an example.

Translate
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