9

Short version:

  • Is there any way I can make MS Word 2007 ( or newer ) encode relative file hyperlinks ( a hyperlink pointing to, e.g., another PDF file ) using the Action Type Launch instead of URI ( both types specified on page 653 of the Adobe Portable Document Format, PDF Reference, version 1.7, sixth edition - http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/pdf_reference_1-7.pdf )? Or is the only solution to implement a post-processor that can change all of the "wrong" URI encoded file hyperlinks to their Launch equivalent?

Elaborated version:

I have two Word documents; doc1.docx and doc2.docx ( both compiled with MS Word 2007 ).

In doc1.docx I place a hyperlink to a PDF version of my second document ( doc2.pdf ) - so now I got:

Properties of the <code>doc2.pdf</code> hyperlink in <code>doc1.docx</code>

I then save the doc1.docx file as both .docx and .pdf - the PDF generation is handled by the built-in PDF-publisher in MS Word 2007 using the following options:

MS Word 2007 PDF Publish Properties

So far so good - I then have the following folder structure:

/superuser
    - doc1.docx
    - doc1.pdf
    - doc2.docx
    - doc2.pdf

Then I open doc1.pdf with Adobe Reader X ( version 10.1.3 ) and click on the hyperlink pointing to doc2.pdf. As the link is relative I would have guessed/assumed that Adobe Reader X would simply open the target PDF file in either a separate window or in the same instance of Adobe Reader X ( depending on the option Open cross-document links in same window specified in: Edit -> Preferences -> Documents ).

However, that is not the case. Instead, Adobe Reader X resolves the hyperlink using the default browser ( in my case Google Chrome v21+ on Windows 7 x64 ) - and to be clear - this is the problem. I want Adobe Reader X ( and most of its predecessors ) to just resolve the hyperlink by opening the target PDF in another instance of Adobe Reader X ( assuming I have unchecked the Open cross-document links in same window option ). Repeating the same scenario using my ( default ) PDF reader; Sumatra PDF works as expected - Sumatra PDF opens the target PDF file in a separate window and shows me the content of doc2.pdf. So why not use Sumatra PDF then you ask? I would have loved to - however, the problem is that I am working on a project with potentially lots of end users, and I cannot assume that all of them use another PDF reader than Adobe Reader X - so, there is no other way around that figuring out what is going on with Adobe Reader X.

So to get there, I started digging.

First, by looking at the address bar in Chrome it is seen that Adobe Reader X tries to resolve doc2.pdf using the file URI scheme: file:///C:/superuser/doc2.pdf - which seems fair to me ( pasting the same URI into the Run dialog in Windows 7 causes my default PDF reader ( Sumatra PDF ) to open the file ) - but why is Adobe Reader X asking the default browser to handle the PDF?

To answer that, I continued digging. Opening doc1.pdf in notepad++ revealed that the hyperlink has been encoded using the URI Action Type ( see p. 653 and 662 in the Adobe Portable Document Format, PDF Reference, version 1.7, sixth edition - http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/pdf_reference_1-7.pdf ):

/Type/Action/S/URI/URI(doc2.pdf)

The PDF reference ( p. 662 ) states the following about the URI Action Type:

A uniform resource identifier (URI) is a string that identifies (resolves to) a resource on the Internet—typically a file that is the destination of a hypertext link, although it can also resolve to a query or other entity.

So, what at first hand looked like a major bug in Adobe Reader X started to look like a fair implementation. At least, at this point I figured out why Adobe Reader X behaves like it does - resulting in a new question to answer: how do I proper encode a file hyperlink ( e.g. a link to doc2.pdf ) such that the resulting PDF is making Adobe Reader X handle the link itself ( instead of asking the default browser to do its job )?

To answer that I took another look at the PDF specification and found the Action Type Launch - about that type, the PDF reference states the following ( p. 659 ):

A launch action launches an application or opens or prints a document.

So by making the following change ( using notepad++ ):

Replacing:

/Type/Action/S/URI/URI(doc2.pdf)

With this:

/Type/Action/S/Launch/F(doc2.pdf)

... Adobe Reader X then resolves the link by opening doc2.pdf file in a separate window / another instance of Adobe Reader X - again assuming I have unchecked the Open cross-document links in same window option (hooray!!).

And now down to the actual / final question that I have not yet managed to solve - is there any way I can make MS Word 2007 ( or newer ) encode relative file hyperlinks ( a hyperlink pointing to, e.g., another PDF file ) using the Action Type Launch instead of URI ( both types specified on page 653 of the Adobe Portable Document Format, PDF Reference, version 1.7, sixth edition - http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/pdf_reference_1-7.pdf )? Or is the only solution to implement some kind of post-processor application that can change all of the "wrong" URI encoded file hyperlinks to their Launch equivalent?

I know this might cause a lot of "TLDR" - but if you manage to get here I really appreciate your interest and I hope that you or someone else can point me in the right direction.

Thanks.

3
  • 2
    Not sure if comments 'bump' a question, but this is worth the read.
    – rtf
    Aug 11, 2012 at 2:39
  • 1
    Thanks for your question. It by itself contains a lot of detail and one possible solution. Did you manage to find a better way of doing it? Replacing the Action works fine.
    – Farish
    Jan 14, 2014 at 9:07
  • 1
    @Farish Unfortunately no. Until now, using a post processor has been the solution that works for me. If I some day find a better way, I will post an update here :) Jan 14, 2014 at 15:15

4 Answers 4

2

Thank you for your excellent article. It works! Not for me at at first but then I discovered you have to turn off 'protected mode' in adobe X. I don't have this problem at all on adobe 9. It seems to me that the industry is going backwards on functionality in the name of security.

So in Adobe Reader X do:

  1. Make sure open cross docs.. is unchecked. (as you said)
  2. Turn off protected mode: Edit » Preferences » General
  3. Search and replace /Type/Action/S/URI/URI with /Type/Action/S/Launch/F( using a suitable hex editor

There is no easy solution for what we want to do which is allow any user with only a PDF reader with no settings to bother about, to navigate around a folder.
But thanks again for all your work and the light it throws on the subject.

1
  • I'm glad that it works using the idea of a "post processor". Since I posted the question I have still not found a better solution, so I will also keep using the post-processing step until a better solution exist. Thanks for your input :) Jan 21, 2013 at 15:57
0

FWIW, I don't think the links work in Sumatra if the file name contains spaces (placing quotes around the name didn't help since Word seems to strip those when creating the link). I don't believe it's possible to change Word's behaviour, so...

Workaround #1: Use a better PDF creator.

Workaround #2: Create PDFs with Word as usual, then use a hex editor or a command-line utility such as http://stahlforce.com/dev/index.php?tool=rep to replace all required instances of /Type/Action/S/URI/URI( with /Type/Action/S/Launch/F(.

0

Re. the relative hyperlink question.

MS Office Help states that the setting 'update links on save' (Office button/Word options button/advanced/ Web otions button) causes the insertion of hyperlinks to be relative. If unchecked, they become absolute. However this setting made no differnce to my attempts. What did, was the point at which the file was saved. For making relative links I open a new blank file and saved it to an appropriate folder before inserting any links. In the 'Insert hyperlink box' choose 'existing folder'. The folder shown in the box is then the folder just saved-in tree'ed downwards - not upwards. i.e. relative

For making absolute links I open a new blank file and without saving it I insert the link. The insert box now shows the existing folder at the top level. Drill down to the file to be linked to and the path shown at the bottom of the box is the full path back to C:. . . . . .. (showing the drive letter) i.e. absolute.

By hovering the cursor over the links in the two Word files shows the full absolute path in both cases. However if the Parent folder is copied to another drive, the relative link opens the folder in the new drive and the absolute link goes back to the C: drive folder, Which I what I want to see. I have not yet discovered how to make both kinds of link in the one file. But I don't need this anyway. I was able to convert both my MS Word files to pdf using your hex-edit modification above, and the they both worked, one in absolute mode the other relative.

Re. your 'hex edit subsitution method'

It worked fine for me in some cases and not others. I found that I had to make sure the target filenames have no spaces in tham. I substitued them with the underscore symbol. Then they worked.

0

I have bottomed this out now as far as reasonably possible for myself. Since it relates directly to the original question I will just pass on my final summary.

Re. absolute and relative links in the same document

look at the path shown at bottom of the Insert hyperlink box. If the top level folder is your chosen folder then the link will be relative to it. To make it absolute use the tree structure in the 'insert' box to drill upwards all the way to the drive letter. The default is for relative links when the file has first been saved to the 'parent' folder.

Steps to Creating a transportable Index-linking Folder

(with an 'index' document linking to files in sub-folders.)

  1. Make a new folder somwhere which will be the folder to be transported ('The Parent' folder).

  2. Make or place sub folders with their files into the Parent.

  3. Now open a Word 2007 document which will be your 'index doc'. Before inserting any links save this this file to your 'parent'.

  4. Now do 'insert hyperlink'. The 'insert hyperlink' box will display the folder/file tree structure downwards from the 'parent' i.e relative. To make an absolute link drill upwards all the way to the drive letter.

  5. Save the Word file which will now work as your 'index doc'

  6. To convert the 'index doc' to pdf open the word file and do save as PDF. This version of the Index doc will open target files via the browser either downloading them or displaying as PDF within the browser.

  7. To make the 'Index.pdf' document open the links in their native application modify the file using the hex edit method described earlier and substite /Type/Action/S/URI/URI( for /Type/Action/S/Launch/F(

  8. 3.Important Note! Before modifying the .pdf file, make sure all folder and file names have no spaces. Subsitute spaces with underscore or dash.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .