9

I use the embedfile package in order to embed the LaTeX source code into the final PDF with the following code:

\documentclass{article}

\usepackage{embedfile}
\embedfile{\jobname.tex}

\begin{document}
The document
\end{document}

This works fine with pdflatex, but now I have to switch to XeLaTeX in order to use a custom TrueType font. However, the embedfile package doesn't support the program dvipdfmx used by XeLaTeX. Is there a way to modify the package to make it cooperate with dvipdfmx, or another package with similar functionality supporting this driver?

(This question is similar, but not identical, to Attach files to PDF with dvipdfmx: In the answers to this question, a way to attach a file to a PDF using dvipdfmx is shown. This creates a visible icon in the document, which is not what I want: The embedded file should only appear in the list of attachments displayed e.g. by Acrobat Reader.)

diabonas
  • 25,784

2 Answers2

6

OK, I figured it out myself: The package navigator works fine with pdflatex and dvipdfmx and supports embedding files through the \embeddedfile macro:

\documentclass{article}

\usepackage{navigator}
\embeddedfile{sourcecode}{\jobname.tex}

\begin{document}
The document
\end{document}

The syntax of the command is

\embeddedfile[<optional description>]{<object name>}[<optional filename displayed in the viewer>]{<file>}
diabonas
  • 25,784
5

Heiko Oberdiek has updated attachfile2 package to support dvipdfmx and XeTeX. Use this version:

http://www.informatik.uni-freiburg.de/~oberdiek/tmp/attachfile2.pdf

(The attachfile2.dtx is attached in the pdf file.)

To avoid the icon, you can use \textattachfile command. For example:

\textattachfile{foo.jpg}{} % no icon or text
Leo Liu
  • 77,365