Including files as attachment with pdflatex

by Martin Monperrus

You may want to include files in a PDF document (for instance sources, graphs, raw data, programs). If you use pdflatex, this can be done with the package ‘’attachfile’’.

\documentclass{article}
\usepackage{attachfile}
\begin{document}

\textattachfile[mimetype=text/html,color=0 0 0.5]{doc-appendix.html}{show me} %% displays "show me"

%% simplest solution
\attachfile{sources.zip}%% displays an icon

\end{document}

See [[http://www.ctan.org/tex-archive/macros/latex/contrib/attachfile/attachfile.pdf|the documentation of attachfile]] for more options. On Debian/Ubuntu ‘’attachfile’’ is in the package ‘’texlive-latex-extra’’.

You can extract the attached files with Adobe Reader of PDF X-Change viewer, as well as with pdftk: ’‘$ pdftk myfile.pdf unpack_files’’

Note that attached files are different from pdftosrc.

Tagged as: