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

Creating a custom button with Javascript

Community Beginner ,
Aug 20, 2020 Aug 20, 2020

Copy link to clipboard

Copied

Hi everyone, 

 

I'm trying to automate a custom button dedicated to page navigation, it would:

   1. Set up a "mouse up" action to go to a destination at the bottom of my PDF.

   2. Create a second button at the desired page in the PDF, it should reference where the original button is.

 

Right now I've created a "destinations" tool to move to a specific page. However, I would like to set the destination to the newly created button and visa-versa. 

 

My employer struggles with technology and I believe creating simple buttons like this will help with the form creation and navigation. 

 

Here's some of my code:

 

("Buttons" is my array of buttons)

for(var j = 0; j < buttons.length; j++){

  if(buttons[j].name.substring(0, 7) == "FINDING"){

      buttons[j].fillColor = color.blue;

      buttons[j].textColor = color.white;

      buttons[j].textSize = 10;

      buttons[j].textFont = font.Helv;

      if(buttons[j].pageNum == 2){***This has not worked either***

           buttons[j].setAction("MouseUp", this.gotoNamedDest("Ref"));

     }

   }

}

 

 

Thanks for the help in advance. I hope this was clear enough and I would like to know if what I want is actually possible. I've realized Adobe is not the easiest to work with. I'm a web developer and Adobe's limitations are becoming increasingly frustrating. 

TOPICS
Acrobat SDK and JavaScript

Views

1.0K

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 ,
Aug 20, 2020 Aug 20, 2020

Copy link to clipboard

Copied

You can create button and as mouse up event choose "Go to a page" to set page and view.
You can create button to go back to previous page using this code:  app.goBack()
or you can go  to specific button if you use code like this: this.getField("Button name").setFocus();
Hope some of this can help you.

Votes

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 ,
Aug 20, 2020 Aug 20, 2020

Copy link to clipboard

Copied

LATEST

- A field object has a page property, not a pageNum property.

- The second parameter of setAction needs to be the code to execute, but in the form of a string, like this:

buttons[j].setAction("MouseUp", "this.gotoNamedDest(\"Ref\")");

Votes

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