[Tex/LaTex] Attaching file into a pdf with pdfLaTeX will crash Adobe Reader

attachfilepdf

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?

Best Answer

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.