I am embedding a PDF file inside my LaTeX-generated PDF file using embedfile:
\usepackage{embedfile}
\embedfile{myfile.pdf}
I would like to also insert a link that the user can click on to open the attachment.
Is there any way to do that?
I am embedding a PDF file inside my LaTeX-generated PDF file using embedfile:
\usepackage{embedfile}
\embedfile{myfile.pdf}
I would like to also insert a link that the user can click on to open the attachment.
Is there any way to do that?
You could use the navigator package instead of embedfile - both packages are quite similar to use (the macro to embed a file is called \embeddedfile instead of \embedfile), but navigator additionally supports the \openfilelink command which creates links to embedded files:
\openfilelink [<appearence options>]{<file name>}[<page number to open>]{<link text>}
A minimal example:
\documentclass{article}
\usepackage{navigator}
\embeddedfile{myfile}{myfile.pdf}
\begin{document}
\paragraph{Demonstration:} \openfilelink{myfile.pdf}{Link to the embedded file \texttt{myfile.pdf}}
\end{document}
If you want a link, use the package attachfile instead of embedfile. The default behavior of a file attached with \attachfile{filename} is to display an icon, but \textattachfile{filename}{<text>} will turn <text> into a link to your embedded file.
attachfile works well, I've been using it for years.
EDIT:
Regarding your trouble with a printout: The manual of attachfile tells you that the boolean option print=true will never print, unless you tell your pdf-viewer to do that -- and most of them, including Acrobat, won't, anyway what you do. You asked for clickable links, not for printouts. . .
But of course it is possible to have all the text printed on paper, e.g. like that:
\documentclass{scrartcl}
\usepackage{calc, attachfile}
\newlength{\Urlname}
\newcommand{\doubleprint}[1]{\setlength{\Urlname}{\widthof{#1}}}
\newcommand{\textattachfileandprintout}[2]{%
\textattachfile[color=0 0 0]{#1}{#2}\doubleprint{#2}\hspace{-\Urlname}#2}
\begin{document}
\textattachfileandprintout{filename}{linktext}
\end{document}
Instead of \textattachfile{}{} use the \textattachfileandprintout or define a shorter command!
Regards, Alexander
\textattachfile[color=0 0 0]{filename}{<text>} to change the text color to black.
– diabonas
May 26 '11 at 09:50
navigator and hypgotoe, this solution also works for bibtex and within SumatraPDF.
– koppor
Feb 26 '18 at 10:15