[pdftex] Attaching and dettaching a file to a PDF
Antonio Lou
alou at mazars.es
Sun Apr 14 23:48:14 CEST 2002
Hello
I'm trying to attach _and_ dettach external files to a PDF in order to get
self-contained files for distribution. So far I have hacked a few LaTeX
macros to do the job:
\newcommand{\insertfile}[2]{
% #1: File path to insert
% #2: Text to show
\immediate\pdfobj stream
attr {/Type /EmbeddedFile}
file {#1}
\makefileannotation{#2}{\the\pdflastobj}
}
\newcommand{\makefileannotation}[2]{
% #1: Text to show
% #2: Reference to the embedded file object
\immediate\pdfobj{
<< /F (#1)
/Type /Filespec
/EF << /F #2\space 0 R >>
>>
}
\fileannotation{#1}{\the\pdflastobj}
}
\newcommand{\fileannotation}[2]{
% #1: Text to show
% #2: Reference to the /Filespec object
\pdfannot{
/Subtype /FileAttachment
/Contents (#1)
/C [ 0 0.60001 1 ]
/FS #2\space 0 R
}
}
So, you can say \insertfile{C:/temp/test.xml}{test.xml} and you get the
file <C:/temp/test.xml> embedded with an annotation in the PDF that enables
you to dettach it (I think this only works with Acrobat > 5).
However, when I open the embedded file from inside the PDF via the built-in
dettach tool , I get a byte at the end of the file (11111111) that wasn't
there before doing the attachment. Any ideas? I'm using pdftex Version
3.14159-1.00a-pretest-20010806 (MiKTeX 2.1)
Thanks,
Toni
More information about the pdftex
mailing list