Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The attachfile package allows files to be embedded within the output PDF of a pdfLaTeX document, and the attachfile2 extends this for dvips use as well.

In an article, the author of dvipdfmx gives a recipe for doing the same thing with that driver instead:

\begin{filecontents*}{example.txt}
this is a text file to be embedded
\end{filecontents*}

\documentclass{article}
\begin{document}
test
\special{pdf:fstream @myfile (example.txt)}%
\special{pdf:ann bbox 0 0 10 10 <<
  /Subtype /FileAttachment /FS << 
    /Type /Filespec /F (example.txt)
      /EF << /F @myfile >> >> 
  /Name /PushPin >>}
\end{document}

However, when I compile this with latex+dvipdfmx, I get the following warning:

** WARNING ** Could not open file: example.txt
** WARNING ** Interpreting special command fstream (pdf:) failed.
** WARNING ** >> at page="1" position="(168.14, 707.125)" (in PDF)
** WARNING ** >> xxx "pdf:fstream @myfile (example.txt)"
]
** WARNING ** Object @myfile used, but not defined. Replaced by null.

Does anyone know what I'm going wrong? (TeX Live 2010, Mac OS X.) It would be great to be able to embed files using this method, since that would facilitate XeTeX use with the attachfile packages.

Update: things seem to work fine in TeX Live 2009. I'm thinking that this is a bug in the latest version of dvipdfmx. Any confirmation on this?

share|improve this question
1  
And the big followup question is: who's got the time to incorporate this into attachfile2? –  Will Robertson Sep 27 '10 at 8:34
2  
dvipdfmx is now supported in a new version of attachfile2 (2010/09/27 v2.6), which can be found on CTAN. –  diabonas May 27 '11 at 11:09
add comment

1 Answer 1

up vote 5 down vote accepted

Thanks to Akira Kakuto on the TeX Live mailing list for the answer to this. The current directory is no longer searched for security reasons, so the relative path must be included in the filename:

\special{pdf:fstream @myfile (./example.txt)}%
\special{pdf:ann bbox 0 0 10 10 <<
  /Subtype /FileAttachment /FS << 
    /Type /Filespec /F (./example.txt)
      /EF << /F @myfile >> >> 
  /Name /PushPin >>}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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