Avatar of GRAEMEBLAND12
GRAEMEBLAND12

asked on 

how do I assign a destination page in adobe acrobat using javascript with a form field button?

I want to create a form field rather than a link in adobe acrobat so I can duplicate it across the document.  The function of the form field  is to take me to a certain page of that document.  The link tool cannot be duplicated and I want to know what the javascript (if any) is for 'go to page 3' so I can use the javascript function in the 'actions' section of a form field.  Hope I have explained my self well enough.

Many thanks
Graeme
JavaScript

Avatar of undefined
Last Comment
btech1
ASKER CERTIFIED SOLUTION
Avatar of btech1
btech1

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of GRAEMEBLAND12
GRAEMEBLAND12

ASKER

Thanks for responding.
I have a 22 page pdf document that users will navigate through using buttons on the top of the page.  One of these buttons will take them to the contents page of the document.  Each page will have a link to the contents page which is on page 3.  Previously I have used the link tool in acrobat and created individual links on each page to navigate the user to the contents page.  I want to know how to use the form field tool to create a link to a page in a document.  The form field is the only button I know of that can be duplicated on each page automatically. Javascript is an option for the acrtion you assign to the form field button.  I have tried 'this.pageNum=3' but this seems to come up with the wrong page.

Avatar of GRAEMEBLAND12
GRAEMEBLAND12

ASKER

btech1

I have just tried 'this.pageNum=+2' and it works thank you for pointing me in the right direction!
Avatar of btech1
btech1

Thanks for the grade A.

Btw, you may already know this this.pageNum=++ advance to next page
Avatar of GRAEMEBLAND12
GRAEMEBLAND12

ASKER

Spoke to soon.  It doesn't work. That code only advances you two pages back or something.

Can you help?
Avatar of GRAEMEBLAND12
GRAEMEBLAND12

ASKER

My mistake it does work. I wish I knew what I was doing.
Avatar of btech1
btech1

No problem. Let me know if need help on this.
Avatar of GRAEMEBLAND12
GRAEMEBLAND12

ASKER

this.pageNum=2 has got me to the contents page which was on page two not three.  Looks like it is fine now.  Thanks again for your help that has been stumped me for about  year and a half.
Avatar of btech1
btech1

Fyi, here is an example to create simple navigational links in the lower left and right corners of each page of the current document. The link in lower left corner goes to the previous page; the one in the lower right corner goes to the next page.

var linkWidth = 36, linkHeight = 18;
for ( var i=0; i < this.numPages; i++)
{
      var cropBox = this.getPageBox("Crop", i);
      var linkRect1 = [0,linkHeight,linkWidth,0];
      var offsetLink = cropBox[2] - cropBox[0] - linkWidth;
      var linkRect2 = [offsetLink,linkHeight,linkWidth + offsetLink,0]
      var lhLink = this.addLink(i, linkRect1);
      var rhLink = this.addLink(i, linkRect2);
      var nextPage = (i + 1) % this.numPages;
      var prevPage = (i - 1) % this.numPages;
      var prevPage = (prevPage>=0) ? prevPage : -prevPage;
      lhLink.setAction( "this.pageNum = " + prevPage);
      lhLink.borderColor = color.red;
      lhLink.borderWidth = 1;
      rhLink.setAction( "this.pageNum = " + nextPage);
      rhLink.borderColor = color.red;
      rhLink.borderWidth = 1;
}

Later!
JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo