These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Changing Internal Hyperlinks

ShaunP
Registered: Feb 16 2010
Posts: 3

I have a document with thousands of hyperlinks to internal destinations. These are not at the top of a page but can be anywhere on the page. The document has a two page layout by default because of a series of pictures that span two pages. I want the links from the two page spreads to lead to a zoomed in view at the destination.

How can I use scripting to change all of the hyperlinks to behave this way?

I have been searching around and putting together code from various places. Here is what I have so far:

for ( var linkPage = 10; linkPage < this.numPages; linkPage++) // loop through each page
	{
		var box = this.getPageBox("Crop", linkPage); // get the page box
		var linksList = this.getLinks(linkPage, box); // get the link
		if linksList > 0
			{
				for (var i=0; i < linksList.length; i++) // loop through each link
					{
						this.zoom = 150; // set zoom to 150%
						this.gotoNamedDest(linksList[i]); // go to current destination
						var destPage=this.pageNum
						linkslist[i].setaction("this.pageNum="+destPage) //set new destination
					}
			}
	}

Will this set the destination to the current location or to the top of that page? If it doesn't work, how can I set it so that it will display the destination at 150%?

One of the problems is that my manager wants it to work so that when a link is clicked, it takes you to the destination, but the [b]Previous View[/b] button will return you to the two page layout with one click. My current attempts have made it into two or more clicks. If two is the minimum, he'll just have to live with it.

Thanks,
ShaunP

try67
Online
Expert
Registered: Oct 30 2008
Posts: 2399
setaction won't work. You need to use setAction (JS is case-sensitive).

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

ShaunP
Registered: Feb 16 2010
Posts: 3
OK, I have been hacking away at this script and I have found a problem. How do I get the name of a destination? The line [b]this.gotoNamedDest(linksList{i});[/b] isn't working because [b]linksList{i}][/b] refers to the link itself, not the destination of the link. How do I get the destination?

PS: I changed [] to {} because of the tags.
try67
Online
Expert
Registered: Oct 30 2008
Posts: 2399
It's not possible to get the list of named destinations in a PDF with a script. You must hard-code it into your script, or read it from some external source, like a text file.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com