"Go to page" command in footer/header?

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
BeachBoy
User
Posts: 4
Joined: Thu Feb 23, 2017 5:03 pm

"Go to page" command in footer/header?

Post by BeachBoy »

I am assembling a lengthy document, hundreds of pages, that will have a table of contents at the beginning. While browsing the document on a device or computer, I would like the user to have the option of quickly and easily returning to the table of contents by clicking some sort of hyperlink in the header or footer. I see where I can create a "go to page" hyperlink in the body of the document, but a) that will often conflict with the body of text on some pages of my document; and b) doing this only affects one page at a time.

Is there a way to put this type of hyperlink in the footer or header?

Many thanks,
Dave
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17910
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: "Go to page" command in footer/header?

Post by Tracker Supp-Stefan »

Hello Dave,

This cna easily be done with some JS. The below is taken directly from this file.

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.

Code: Select all

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;
}
You can easily modify that so that the "setAction" is e.g. "this.pageNum = "+ 5 (if your table of contents is on the 6th page of your document).

To execute this JS code - open the JS console in the Editor with Ctrl+J.

Regards,
Stefan
Post Reply