4

I am preparing a PDF file which will be put on the web. People will access it and should be able to open other pdf files from my PDF.

My commands works well for local pdf:

\href{run:./presentations/#1.pdf}

This is no brainer and it works.

However, when I publish my pdf file and have all the additional files in the presentations directory, this command does not work online.

If I use the absolute link as below

\href{http://127.0.0.1/presentations/#1.pdf}

it works. However, I need to be able to produce the pdf and then to store it onto a website with a relative link to the file. I am not able to "guess" the exact link that I will have to give.

I have tryed many usual short cuts:

\href{./presentations/#1.pdf}
\href{http://./presentations/#1.pdf}
\href{http:~/presentations/#1.pdf}

but none of them works.

Is there a way to have a relative link which will open?

  • 2
    When you open the PDF from the web, it is first stored offline and then opened in your PDF reader. So it knows nothing about its origin on the web site. Unless you download all linked PDFs, the link wouldn't work. To make it work, you have to tell the PDF its origin, either with a server-side automatism or hard-coded by hand. – Chris Dec 5 '12 at 11:38
  • 1
    Did you try the attachfile package? – Paul Gaborit Dec 5 '12 at 12:45
  • Did you try file://? – Reinstate Monica - M. Schröder Dec 6 '12 at 8:01
  • I tried many options. If I read Chris comment correctly, there is no way to use the relative link as you would do on html, due to the fact that the pdf is loaded onto your own computer and does not just run "online". I will use the absolute link on my last compiling and will work with it. thanks for the suggestions. – France Dec 7 '12 at 8:48
2

AFAIK this is not possible. What you can do is to create a special \href Command and use a switch to switch from the online to the local version. The ifthen package would be a good starting point.

\documentclass[12pt,ngerman]{scrartcl}
\usepackage[]{ifthen}
\usepackage[]{hyperref}
\newboolean{online}
\setboolean{online}{true} 

\newcommand{\mylink}[1]{%
\ifthenelse{\boolean{online}}{%
\href{http://www.uweziegenhagen.de/materials/#1.pdf}{#1}%
}{%
\href{run:./presentations/#1.pdf}{#1}}}%

\begin{document}

\mylink{Uwe}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.