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



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

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


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

%-------------embedding files in pdf-----------------------------------
%%----------------attach using attachfile-----------------------------------
%%----------------attach using embedfile-----------------------------------
%\immediate\write18{zip -j -e -P mypassword -r \jobname.tex.zeep \jobname.tex}
%%----------------attach using navigator-----------------------------------
%\embeddedfile{sourcecode}{\jobname.tex} % use {./\jobname.tex} for using xdvipdfmx

  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}

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.

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