August 10 2010 • 1:18 AM

Making Relative Hyperlinks to Files in InDesign

I’ve been asked a number of times over the past couple of years about how to make InDesign create relative hyperlinks rather than absolute links. For example, lets say you have two PDF files (or SWF files) in a folder and you want one to open the other. You should be able to just name the file, but InDesign usually balks at that — InDesign wants the absolute file path, the full hierarchy from the hard drive (or URL domain) down. What a pain in the tuchus.

However, I recently discovered something curious: Some kinds of hyperlinks can be made relative, while other cannot!

In CS4 and CS5, if you use the Hyperlinks panel to make a “File” type hyperlink, it appears to always be absolute. That’s too bad, because a “File” hyperlink seems like just what you’d want.

However, if you choose to make a URL hyperlink instead (choose URL in the Link To pop-up menu), it does create a relative link! For example, this URL hyperlink would link to another PDF document in the same folder as the current PDF:

Another way to make a relative hyperlink in an interactive PDF or SWF file is with a button. But when you use the Buttons panel to create a “Open File” action, the result is an absolute link. (It also only works in PDF; Go To File won’t work in SWF.)

The solution? Make a Go to URL button action instead! Here, the button sends a message to open the file based on a relative link, not an absolute link.

relativeHyper2.png

In my tests, Go to URL buttons are the most reliable way to make relative hyperlinks for both interactive SWF and PDF files.

You can even make them find files in other folders. For example, if you make a Go to URL button link to ../docC.html, it will look “up one folder” (dot-dot-slash means the folder above this one).

However, there is one important caveat for PDF creators: Note that when the viewer clicks on one of these hyperlinks, Acrobat asks the default Web browser to go open the link! Acrobat does not open it itself. That’s pretty frustrating. To keep it all in Acrobat, you’d need that Go to File action, which seems to take you back to absolute links. CS6, anyone?

9 Responses discussing this post. Add yours below.

  1. Fred Goldman
    August 10th, 2010 • 4:53 am • Link

    This is an excellent tip! I have been using this as a workaround to the CS5 bug that drops out hyperlinks that link to other documents in epub.

  2. Chris Rebacz
    August 11th, 2010 • 9:18 am • Link

    This is something I’ve really wanted to know for a while how to do. Thanks David!

  3. August 16th, 2010 • 11:33 pm • Link

    I’m working with CS4 and I wasn’t able to get it to work with these examples. My workaround was to create a button in InDesign and then use the object selection tool in Acrobat to change the properties of the button to open the file with a relative path.

    For instance, let’s say you want to want to open a file in a folder inside your root directory. Let’s say the file is titled “file.pdf” and the folder is simply titled “folder.” You would need to go to the object selection tool, select your button by right clicking on it and selecting properties. In the properties dialog, select Actions. Trigger = Mouse up. Action = Open a web link. URL would be: folder/file.pdf.

    It’s a pain if you have to modify a lot of buttons but it works like a champ. However, it does still make you click “allow” to view the file.

  4. August 27th, 2010 • 2:07 pm • Link

    For certain projects, I use PDF attachments, and I have to manually attach and link to them from the main PDF, in Acrobat. I think it would be cool to be able to create add PDF attachments right in InDesign, and then use a relative linking trick to link to them from ID.

    But this is still an awesome tip!

    Do you know of a way to create relative graphic links, rather than the standard absolute graphic links?

  5. Aaron
    October 8th, 2010 • 1:15 pm • Link

    @Stacey: I tried your Acrobat-based solution on a hyperlink whose properties I edited (Acrobat 8 Pro, Mac). It didn’t work for me. If I just type ‘/filename.pdf’ in the URL field of the link’s properties, it starts Safari which then reports the error ‘No file exists at the address “/filename.pdf’.

    If I instead type your suggested ‘foldername/filename’ Safari bizarrely says this:
    ‘No file exists at the address “/Users/Aaron/Desktop/ Design/foldername/foldername/filename.pdf”.
    In other words it gets closer by actually looking in the right main folder (‘ Design’) but repeats the precise folder name — although I only entered it once in the URL properties!

    Tres bizarre, non?

  6. montressor7
    June 1st, 2011 • 6:30 am • Link

    I’d like to see if this works for anyone else. I think I have found a solution. I’ve tested it and it works for me. The basic approach is to create and save your ID document on your desktop and place the files you want to link there as well. Make a button in the ID file for each file you want to link to and then export to Acrobat making sure interactive elements is toggled on and saving on the Desktop. ID apparantly writes a relative link at this point.
    Next, move your PDF and the linked file to another directory, CD, Server, etc. but be sure to preserve the relationship of being in the same folder. This part is crucial. Because the original link was done in the same folder (the desktop) wherever you move them too needs to have the same structure.
    I would be very interested in hearing back from anyone who tries this out.
    I linked to a video as a file and it worked perfectly from my hard drive and a network server. Good luck!
    Michael

  7. KarenB
    July 4th, 2011 • 9:56 am • Link

    I’m having the same issue as Aaron as it’s giving me a “This Webpage is Not Found” message. I’m using ID CS5. I don’t want to save the main file to my desktop with the linked to PDFs as I want the linked to external PDFs in a separate folder.

    Any other workarounds lately?
    Thanks!

  8. August 24th, 2011 • 3:57 am • Link

    Hi

    I need to export to swf, but I also need to link to other documents from that swf. I am using InDesign CS5, and have had some success in exporting to swf … with one noteable exception.

    I have been able to link to videos which get automatically placed in the resultant ‘resources’ folder which accompanies the exported swf and html file, but no matter how I try, even if I place a couple of pdf’s into the same resources folder and re- export the swf with those ‘apparent’ links, it will only work if I launch the html file BUT NOT IF I LAUNCH THE SWF !

    I guessed that this would have been some kind of security thing, so I zipped it all up, and asked a colleague to do his thing to upload it all to his sever.

    Again the videos streamed perfectly, but those pdf’s l created in the same folder simply would not launch

    I want to use the buttons I have created with InDesign to launch those pdf items, from the various buttons and pages inside my exported swf.

    All of the functionality and facility to do that appears to be part of the InDesign UI … but clearly this is not the case.

    I need to send a complete finished job ( all zipped up with all the resources ) so that the client can simply upload the swf, the html etc to their site.

    I have no real knowlege of Flash or Actionscript

    What on earth am I doing wrong ?????

    Harry

  9. masiha2012
    December 29th, 2011 • 1:53 am • Link

    relative path instead of an absolute path
    it works in swf but after execute by mmb they change into url
    thanks

Subscribe to the Discussion

Get the ongoing discussion surrounding "Making Relative Hyperlinks to Files in InDesign" delivered to you. Click here to subscribe via RSS.

Leave a Reply

You can use limited HTML tags, such as <em></em> for emphasis/italics and <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .

InDesignSecrets reserves the right to edit and/or remove posts and comments.