Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie Javascript question

Status
Not open for further replies.

taupirho

Programmer
Jun 25, 2002
680
0
0
GB
I have Adobe Acrobat version 8 Professional

Lets say I have a two page PDF document . On page 1 I have some text that says Goto Page 2 for instance. Is it possible using Javascript to alter that text to be a hyperlink so that when a user clicks it it will indeed take them to page 2? If anyone can provide some sample code that would be would be great.




In order to understand recursion, you must first understand recursion.
 
No Script required.

In Acrobat open the advanced editing toolbar by right clicking on any toolbar.

With the link tool (looks like chain links) draw a box around the words you wish to use. In the dialog box you want to select go to a page view, and set any formatting options for your hyperlink. When you click Next it will ask you to navigate to the page you want the link to navigate to. Once you have it visible on the screen - click the set link button.
 
I needed it to be automated, but thanks anyway. I have found a solution. Suppose I want to search for all occurrences of the word China in a PDF document, then make each of them a link which takes the user to page 8 say when clicked. Hope this will help others in a similar situation.

for (var p = 0; p < this.numPages; p++)
{
var numWords = this.getPageNumWords(p);
for (var i=0; i<numWords; i++)
{
var ckWord = this.getPageNthWord(p, i, true);
if ( ckWord == "China")
{
var q = this.getPageNthWordQuads(p, i);
// Convert quads in default user space to rotated
// User space used by Links.
m = (new Matrix2D).fromRotated(this,p);
mInv = m.invert()
r = mInv.transform(q)
r=r.toString()
r = r.split(",");
l = addLink(p, [r[4], r[5], r[2], r[3]]);
// Uncomment the lines below if you want to "see" the link
//l.borderColor = color.red;
//l.borderWidth = 1;
l.setAction("this.pageNum=8");

}
}
}



In order to understand recursion, you must first understand recursion.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top