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

Redirecting links

malatorr
Registered: Jun 21 2009
Posts: 3

My client has a coorporation with several computers that hourly access pdf documents from a repository. These documents have links to other pdfs, to places inside the document, and to external pages. Some of them are broken or point to a wrong place. Today Im starting to deal with acroJS as a possible solution to handle clicks to avoid the problem.

One possible solution is to install a .js that detects clicks on urls in every machine in the directory "C:\Program Files\Adobe\Reader 9.0\Reader\Javascripts". This script should be able to identify the url and decide whether to go to the original url or to go a different place. Something like this.

// begin pseudo javascript of what I would like to do:
function onSomebodyClickedAlinkInsideAPDF(url){
  if(url_is_wrong(url)){
     browser.location ="http://www.google.com"
  }else{
     // if url is ok, we go to the original url
     browser.location =url
  }
}

The first thing I need to find out is : is this possible whithout modifying any pdf file? just by puting a a javascript in that directory?

try67
Expert
Registered: Oct 30 2008
Posts: 2399
No, unless those links already use some kind of global, folder-level script which you can edit.
I think they are probably "plain" http links pointing to different locations. In that case you can't capture or change their destination with JS.
The only way to do it is to replace all of them with a JS script that calls your global function.

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

malatorr
Registered: Jun 21 2009
Posts: 3
Thank yuo try67,

Could you tell me more about this idea of replacing all links with a JS script? which JS method can modify pdf links sequentially on load time? Would it be something like:

again pseudo code...
if (document.openning ==TRUE){linksObjects = getDocumentLinks()foreach linkObject (linkObjects){if(linkObject.url == XXX){linkObject.url == newURL}}}

If I could do exactly this...it would be perfect!!! but it must be when the user is loading the pdf...I can not modify all pdf documents in the server.

Or maybe you could recommend me another technology to detect a user clicking a link in a pdf?

I was reading the acrobat javascript scripting reference (acrojs.pdf 7) and I see there are mouse events and also methods like getlinks, addlinks...but I dont know exactly if that can solve my problem.

Maybe an activex, I dont know...help please.
try67
Expert
Registered: Oct 30 2008
Posts: 2399
Yes, the pseudo-code you wrote is more or less what this script can do, and it will indeed load when the PDF is opened, through a folder-level script.
However, it will require that you replace all the links in all of your files, just once, so that they will all point to this script. There's no other way of doing it (not with a script, anyway. It might be possible with a plugin).

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