\attachfile{file}{text}
allows me to click on the word "text" and it tries to open/save the
file "file". However, I would like to reference this file "file"
several times throughout my document. That is, I'd like to have
several links throughout the document so that when the link is clicked
on, it prompts me to open/save the file each time. I don't want to
have to attach the file each time because I'd have several occurances
of the file. I'd simply like to have one attachment and several links.
Any thoughts on how to accomplish this?
Thanks in advance,
Troy Henderson
\newcommand\myfile{file}
\attachfile{\myfile}{text}
or
\newcommand\attachmyfile[1]{\attachfile{file}{#1}}
\attachmyfile{text}
or even
\newcommand\attachmyfile{\attachfile{file}{text}}
\attachmyfile
Depending on how much flexibility you want.
Regards
Michael.
"tlhiv" <then...@gmail.com> schreef in bericht
news:1135607696....@f14g2000cwb.googlegroups.com...
I'm not quite sure what you're talking about. The "attachfile" package is
a package for embedding external files into the PDF created by pdf(la)tex.
http://www.ctan.org/tex-archive/macros/latex/contrib/attachfile/
It provides a nice way to attach these files (and link to them), but it
doesn't seem trivial to link to the same file several times without
attaching it several times.
Troy
The following seems to work and to embed a file only once. But I know
up to nothing about pdf annotations, so I really don't know if and
under which conditions this can break ;-)
\documentclass[a4paper]{article}
\usepackage{attachfile}
\makeatletter
\DeclareRobustCommand{\Copyattachfile}[2][]{%
\begingroup
\setkeys{AtFi}{#1}%
%\atfi@embedfile{#2}%
\atfi@set@appearance{\csname atfi@acro\atfi@icon@icon\endcsname}%
\atfi@flags@to@int%
\atfi@insert@file@annot{#2}%
\endgroup
}
\makeatother
\begin{document}
\attachfile{largefile.tex}
\newpage
\Copyattachfile{largefile.tex}
\end{document}
--
Ulrike Fischer
e-mail: zusätzlich meinen Vornamen vor dem @ einfügen.
e-mail: add my first name between the news and the @.
Thanks for the reply. This command seems to attach the file again.
Troy
> Ulrike,
>
> Thanks for the reply. This command seems to attach the file again.
? I'm not quite sure I don't understand what you mean. On my system the
file is attached only once:
with attachfile+ \Copyattachfile
<<largefile.tex>> [1{psfonts.map}] [2]
Output written on test.pdf (2 pages, 43629 bytes)
with two \attachfiles:
<<largefile.tex>> [1{psfonts.map}]<<largefile.tex>> [2]
Output written on test.pdf (2 pages, 81237 bytes).
> When I open the file in Adobe Acrobat Reader and go to the file
> attachments, it shows the file twice.
That's life, it shows the file annotations and you have two of them.
Yours sincerely
Heiko <ober...@uni-freiburg.de>
Troy
Thanks guys. This is good enough.
Troy
Troy
> The filesize definitely increases (not just a little either) when using
> this command \Copyattachfile The magnitude of the change is similar to
> that of the filesize of the file I'm attaching.
I wouldn't be surprized if you had problems to open the attached files,
but I don't think it it is possible that \Copyattachfile embeds a file.
The embedding is done with the command
%\atfi@embedfile{#2}%
And as it isn't there in \Copyattachfile, nothing can be embeded.
What does the log-file tells you at the end?
Btw: I realized that I have use the definition of a quite old
attachfile. With newer one the following should be better:
\makeatletter
\DeclareRobustCommand{\Copyattachfile}[1][]{%
\begingroup
\let\do\@makeother
\dospecials
\catcode`\{=1\relax
\catcode`\}=2\relax
\atfi@copyattachfile{#1}%
}
\def\atfi@copyattachfile#1#2{%
\setkeys{AtFi}{#1}%
%\atfi@embedfile{#2}%
\atfi@set@appearance{\csname atfi@acro\atfi@icon@icon\endcsname}%
\atfi@flags@to@int%
\atfi@insert@file@annot{#2}%
\endgroup
}
\makeatother
> Now I just need to get a corresponding \copytextattachfile working.
Simply look in attachfile.sty, search the definitions and change them.
The following should word (untested).
Btw: I want to emphasize that I don't understand all this stuff. I only
looked up the commands and tried to disable the embedding. So be
careful and do some tests in different environments.
\makeatletter
\DeclareRobustCommand{\Copytextattachfile}[1][]{% changed
\begingroup
\begingroup
\let\do\@makeother
\dospecials
\catcode`\{=1\relax
\catcode`\}=2\relax
\atfi@Copytextattachfile{#1}% changed
}
\def\atfi@Copytextattachfile#1#2{% changed
\endgroup
\atfi@Copytextattachfile@i{#1}{#2}% changed
}
\def\atfi@Copytextattachfile@i#1#2#3{% changed
\setkeys{AtFi}{#1}%
%\atfi@embedfile{#2}% changed
\def\atfi@textcolor(##1 ##2 ##3)##4{%
\textcolor[rgb]{##1,##2,##3}{##4}}%
\atfi@set@appearance{%
\expandafter\atfi@textcolor\expandafter
(\atfi@color@rgb){#3\strut}}%
\atfi@flags@to@int
\atfi@insert@file@annot{#2}%
\endgroup
}
\makeatother
Troy
Troy
Simply removing \atfi@embedfile will probably put an incorrect reference
into the pdf file. Therefore, one has to keep track of the object number
when embedding it the first time to be able to recall it later.
Here is a minimally corrected version of Ulrike's code:
\DeclareRobustCommand{\atfi@embedfile}[1]{%
\immediate\pdfobj stream attr {
/Type /EmbeddedFile
\atfi@mimetype
} file {#1}%
\setcounter{atfi@embedfileobj}{\pdflastobj}%
% [RS]: save object number
\expandafter\xdef
\csname atfi@embedfileobj@#1\endcsname{\the\pdflastobj}%
}
\DeclareRobustCommand{\Copytextattachfile}[1][]{% changed
\begingroup
\begingroup
\let\do\@makeother
\dospecials
\catcode`\{=1\relax
\catcode`\}=2\relax
\atfi@Copytextattachfile{#1}% changed
}
\def\atfi@Copytextattachfile#1#2{% changed
\endgroup
\atfi@Copytextattachfile@i{#1}{#2}% changed
}
\def\atfi@Copytextattachfile@i#1#2#3{% changed
\setkeys{AtFi}{#1}%
%\atfi@embedfile{#2}% changed
\def\atfi@textcolor(##1 ##2 ##3)##4{%
\textcolor[rgb]{##1,##2,##3}{##4}}%
\atfi@set@appearance{%
\expandafter\atfi@textcolor\expandafter
(\atfi@color@rgb){#3\strut}}%
\atfi@flags@to@int
% [RS]: recall object number
\expandafter\c@atfi@embedfileobj
\csname atfi@embedfileobj@#2\endcsname\relax
\atfi@insert@file@annot{#2}%
\endgroup
}
Regards,
Robert.
Thanks for the correction. Unfortunately, it doesn't seem to quite work
here. It complains about
! Missing number, treated as zero.
<to be read again>
\atfi@embedfileobj@tri.mp
l.207 \Copytextattachfile{tri.mp}{some text}
where "tri.mp" is the name of the file I'm re-referencing. Any help on
fixing this would be greatly appreciated.
Troy
I guess you did not use the normal \textattachfile command for the first
attachment?
With the following, much simpler approach, this is no longer necessary:
\documentclass{article}
\usepackage{attachfile}
\makeatletter
\DeclareRobustCommand{\atfi@embedfile}[1]{%
\@ifundefined{atfi@embedfileobj@#1}{%
\immediate\pdfobj stream attr {
/Type /EmbeddedFile
\atfi@mimetype
} file {#1}%
\setcounter{atfi@embedfileobj}{\pdflastobj}%
\expandafter\xdef
\csname atfi@embedfileobj@#1\endcsname{\the\pdflastobj}%
}{%
\setcounter{atfi@embedfileobj}%
{\csname atfi@embedfileobj@#1\endcsname}%
}%
}
\makeatother
\begin{document}
\attachfile{test1.tex}
\newpage
\textattachfile{test2.tex}{test2}
\newpage
\textattachfile{test1.tex}{test1}
\attachfile{test2.tex}
\end{document}
Regards,
Robert.
You're the man. Perhaps you should contact the author to let him know
about this. I think this should be an update to the package.
Thanks a bunch,
Troy
It's now on my to-do list.
-- Scott
You live. Thanks for the attention. Do you know if it's a
feature/flaw in Acroread/Acrobat that even though the file is embedded
only once, that it shows up several (as many times as it's "referenced")
in the "Attachment List"?
Troy
I don't know but I'd guess it's a flaw. I can't think of why one would
want to see the same attachment listed multiple times.
-- Scott