9

I am using the package attachfile to attach a file to the pdf (generated with pdfLaTeX) with the following code

\documentclass[twoside,a4paper,10pt]{article}
\usepackage{attachfile}

\begin{document}
  \title{XXX}
  \author{YYY}
  \maketitle

  Here is the file I attached: \attachfile{file.txt}
\end{document}

It compiles without any problem and the pdf will be generated then. But if I open it in Adobe Reader X, it crashes. Interestingly, if I open that in Acrobat 7, it works. Is that any better way to insert file to the pdf so to support different version of pdf reader?

1 Answer 1

10

You can use embedfile and/or navigator also to attach files.

%-------------embedding files in pdf-----------------------------------
\documentclass{article}
%%----------------attach using attachfile-----------------------------------
\usepackage{attachfile}
%\attachfile{\jobname.tex}
%%----------------attach using embedfile-----------------------------------
%\usepackage{embedfile}
%\immediate\write18{zip -j -e -P mypassword -r \jobname.tex.zeep \jobname.tex}
%\embedfile{\jobname.tex}
%%----------------attach using navigator-----------------------------------
\usepackage{navigator}
%\embeddedfile{sourcecode}{\jobname.tex} % use {./\jobname.tex} for using xdvipdfmx
%%---------------------------------------------------
\begin{document}
  \title{XXX}
  \author{YYY}
  \maketitle

  Here is the file I attached: \attachfile{rate.txt}

  Here is the file I attached: \embeddedfile{sourcecode}{rate.txt} 

 % Here is the file I attached: \embedfile{rate.txt}
\end{document}

You may try the best option that fits for your setup.

enter image description here

But in Adobe Acrobat X Pro, the attachfile works for me.

3
  • Hi Harish, I try your example. navigator works, it can insert the text file. But to use embedfile package, the pdflatex crashs during compiling. Though navigator works in inserting the file, what I want is to put an icon at the place I insert the file like it does in attachfile. It seems that navigator will only insert the file but no icon created. Commented Jan 22, 2013 at 2:39
  • @user1285419 In general terms all of these methods work. That suggests there is something up either with your attached file or with your TeX set up. Could you make the file and a pdfLaTeX log available somewhere?
    – Joseph Wright
    Commented Jan 22, 2013 at 6:56
  • It is pretty weird. I don't know what's going on, I try it in other computer, the same thing happens. But what's really strange is if I open the resulting pdf in acrobat professional or other viewer like SumatraPDF, it works without any problem :( I put all the src, pdf and log over here filehost.ws/a5om64hp1o6s Commented Jan 22, 2013 at 8:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .