Creating a custom button with Javascript

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, Create PDFs, General troubleshooting, How to

Views

46

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

Creating a custom button with Javascript

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, Create PDFs, General troubleshooting, How to

Views

47

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

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
Reply
Loading...
Aug 20, 2020 2
try67 LATEST
Aug 20, 2020

Copy link to clipboard

Copied

- 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\")");

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
Reply
Loading...
Aug 20, 2020 1