[Tex/LaTex] Embedding files into a PDF document with dvipdfmx

dvipdfmxembeddingpdf

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.)

Best Answer

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>}
Related Question