summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/oberdiek/attachfile2.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/oberdiek/attachfile2.dtx')
-rw-r--r--Master/texmf-dist/source/latex/oberdiek/attachfile2.dtx1743
1 files changed, 1293 insertions, 450 deletions
diff --git a/Master/texmf-dist/source/latex/oberdiek/attachfile2.dtx b/Master/texmf-dist/source/latex/oberdiek/attachfile2.dtx
index 82632957b4f..d3db746afdb 100644
--- a/Master/texmf-dist/source/latex/oberdiek/attachfile2.dtx
+++ b/Master/texmf-dist/source/latex/oberdiek/attachfile2.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright (C) 2005-2009 by
+% Copyright (C) 2005-2010 by
% Heiko Oberdiek <heiko.oberdiek at googlemail.com>
%
% This work may be distributed and/or modified under the
@@ -20,7 +20,8 @@
% This work consists of the main source file attachfile2.dtx
% and the derived files
% attachfile2.sty, attachfile2.pdf, attachfile2.ins, attachfile2.drv,
-% atfidvips.def, atfipdftex.def, pdfatfi.pl.
+% atfi-dvips.def, atfi-pdftex.def, atfi-dvipdfmx.def,
+% pdfatfi.pl.
%
% Distribution:
% CTAN:macros/latex/contrib/oberdiek/attachfile2.dtx
@@ -54,8 +55,9 @@
%
% Installation:
% TDS:tex/latex/oberdiek/attachfile2.sty
-% TDS:tex/latex/oberdiek/atfidvips.def
-% TDS:tex/latex/oberdiek/atfipdftex.def
+% TDS:tex/latex/oberdiek/atfi-dvips.def
+% TDS:tex/latex/oberdiek/atfi-pdftex.def
+% TDS:tex/latex/oberdiek/atfi-dvipdfmx.def
% TDS:scripts/oberdiek/pdfatfi.pl (exec flag)
% TDS:doc/latex/oberdiek/attachfile2.pdf
% TDS:source/latex/oberdiek/attachfile2.dtx
@@ -75,7 +77,7 @@
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
-\Msg{* Package: attachfile2 2009/09/25 v2.5 attach files into PDF (HO)}
+\Msg{* Package: attachfile2 2010/09/27 v2.6 attach files into PDF (HO)}
\Msg{************************************************************************}
\keepsilent
@@ -86,7 +88,7 @@
This is a generated file.
-Copyright (C) 2005-2009 by
+Copyright (C) 2005-2010 by
Heiko Oberdiek <heiko.oberdiek at googlemail.com>
This work may be distributed and/or modified under the
@@ -106,7 +108,8 @@ This Current Maintainer of this work is Heiko Oberdiek.
This work consists of the main source file attachfile2.dtx
and the derived files
attachfile2.sty, attachfile2.pdf, attachfile2.ins, attachfile2.drv,
- atfidvips.def, atfipdftex.def, pdfatfi.pl.
+ atfi-dvips.def, atfi-pdftex.def, atfi-dvipdfmx.def,
+ pdfatfi.pl.
\endpreamble
\let\MetaPrefix\DoubleperCent
@@ -116,8 +119,9 @@ and the derived files
\file{attachfile2.drv}{\from{attachfile2.dtx}{driver}}%
\usedir{tex/latex/oberdiek}%
\file{attachfile2.sty}{\from{attachfile2.dtx}{package}}%
- \file{atfidvips.def}{\from{attachfile2.dtx}{dvips}}%
- \file{atfipdftex.def}{\from{attachfile2.dtx}{pdftex}}%
+ \file{atfi-dvips.def}{\from{attachfile2.dtx}{dvips}}%
+ \file{atfi-pdftex.def}{\from{attachfile2.dtx}{pdftex}}%
+ \file{atfi-dvipdfmx.def}{\from{attachfile2.dtx}{dvipdfmx}}%
\nopreamble
\nopostamble
\usedir{scripts/oberdiek}%
@@ -132,7 +136,8 @@ and the derived files
\Msg{* To finish the installation you have to move the following}
\Msg{* files into a directory searched by TeX:}
\Msg{*}
-\Msg{* attachfile2.sty, atfidvips.def, atfipdftex.def}
+\Msg{* attachfile2.sty, atfi-dvips.def, atfi-pdftex.def,}
+\Msg{* atfi-dvipdfmx.def}
\Msg{*}
\Msg{* And install the following script file:}
\Msg{*}
@@ -153,7 +158,7 @@ and the derived files
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{attachfile2.drv}%
- [2009/09/25 v2.5 attach files into PDF (HO)]%
+ [2010/09/27 v2.6 attach files into PDF (HO)]%
\documentclass{ltxdoc}
\usepackage{holtxdoc}[2008/08/11]
\begin{document}
@@ -162,7 +167,7 @@ and the derived files
%</driver>
% \fi
%
-% \CheckSum{1405}
+% \CheckSum{1744}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -183,7 +188,7 @@ and the derived files
% \GetFileInfo{attachfile2.drv}
%
% \title{The \xpackage{attachfile2} package}
-% \date{2009/09/25 v2.5}
+% \date{2010/09/27 v2.6}
% \author{Heiko Oberdiek\\\xemail{heiko.oberdiek at googlemail.com}}
%
% \maketitle
@@ -284,7 +289,11 @@ and the derived files
%
% \subsubsection{New options}
% \begin{itemize}
-% \item Driver options \xoption{dvips} and \xoption{pdftex}.
+% \item Driver options \xoption{dvips}, \xoption{pdftex},
+% \xoption{dvipdfmx} and \xoption{xetex} that is an
+% alias for \xoption{dvipdfmx}.
+% \item Option \xoption{driverfallback} specifies a DVI driver
+% if the driver cannot be detected automatically.
% \item New options \xoption{final} and \xoption{draft}.
% \item New option \xoption{scale} for scaling the annotation rectangle.
% \item Options \xoption{file} and \xoption{nofile} for controlling
@@ -360,8 +369,10 @@ and the derived files
% such as file size, file date, checksum, \dots.
% As package \xpackage{embedfile} shows the new features
% of \pdfTeX\ 1.30 are very useful for getting this kind of
-% data. However the main development preceded this \pdfTeX\ version.
-% Thus the Perl script \xfile{pdfatfi.pl} is used to provide this data.
+% data. Since version 2.6 these data are used if available.
+%
+% For older versions of \pdfTeX\ and \XeTeX\ the Perl script
+% \xfile{pdfatfi.pl} is provided to get this data.
% The use of the Perl script is not mandatory. This data can be shown
% by PDF viewers, but they are not a requirement of the PDF specification.
%
@@ -384,6 +395,7 @@ and the derived files
% Some of the changes I can remember:
% \begin{itemize}
% \item Support for dvips.
+% \item Support for dvipdfmx/\XeTeX.
% \item Setting and filling the /Param entry for files
% (file date, file size, \dots).
% \item Perl script \xfile{pdfatfi.pl}.
@@ -403,149 +415,215 @@ and the derived files
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{attachfile2}%
- [2009/09/25 v2.5 attach files into PDF (HO)]%
+ [2010/09/27 v2.6 attach files into PDF (HO)]%
% \end{macrocode}
+%
+% \subsubsection{Loading of packages}
+%
% \begin{macrocode}
-\RequirePackage{ifpdf}
+\RequirePackage{ifpdf}[2009/04/10]
+\RequirePackage{ifxetex}
+\RequirePackage{ifluatex}[2009/04/10]
\RequirePackage{keyval}
\RequirePackage{color}
-\RequirePackage{kvoptions}[2006/08/17]
+\RequirePackage{infwarerr}[2010/04/08]
+\RequirePackage{ltxcmds}[2010/04/26]
+\RequirePackage{kvoptions}[2009/07/21]
+\RequirePackage{pdftexcmds}[2010/04/01]
\RequirePackage{pdfescape}[2007/11/11]
-
-% --- hyperref ---
-
+% \end{macrocode}
+% Package \xpackage{hyperref} is needed because of \cs{pdfstringdef}.
+% \begin{macrocode}
\RequirePackage{hyperref}
-% because of \pdfstringdef
\RequirePackage{hycolor}[2008/07/29]
-
-% --- convert to hex ---
-
-\def\atfi@hexdigit#1{%
- \ifcase#1%
- 0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or 8\or 9\or
- a\or b\or c\or d\or e\or f%
- \fi
-}
-% detour via \dimexpr to avoid eTeX's nasty expression rounding
-\def\atfi@hexchar#1{%
- \atfi@hexdigit{\numexpr\dimexpr.0625\dimexpr`#1sp\relax\relax\relax}%
- \atfi@hexdigit{%
- \numexpr`#1-16*\dimexpr.0625\dimexpr`#1sp\relax\relax\relax
+% \end{macrocode}
+%
+% \subsubsection{Value checking}
+%
+% \begin{macro}{\atfi@Match}
+% \begin{macrocode}
+\ltx@IfUndefined{pdfmatch}{%
+ \def\atfi@Match#1#2#3#4#5{}%
+}{%
+ \def\atfi@Match#1#2#3{%
+ \begingroup
+ \edef\^{\ltx@backslashchar\string^}%
+ \edef\.{\ltx@backslashchar.}%
+ \let\#\ltx@hashchar
+ \edef\[{\ltx@backslashchar[}% ]]
+ \edef\${\ltx@backslashchar$}%
+ \let\%\ltx@percentchar
+ \edef\&{\string&}%
+ \edef\({\ltx@backslashchar(}%
+ \edef\){\ltx@backslashchar)}%
+ \edef\|{\ltx@backslashchar|}%
+ \edef\*{\ltx@backslashchar*}%
+ \edef\+{\ltx@backslashchar+}%
+ \edef\?{\ltx@backslashchar?}%
+ \edef\{{\ltx@backslashchar\ltx@leftbracechar}%
+ \edef\}{\ltx@rightbracechar}%
+ \edef\\{\ltx@backslashchar\ltx@backslashchar}%
+ \edef\~{\string~}%
+ \ifcase\pdfmatch#3{#2}{#1} %
+ \endgroup
+ \expandafter\ltx@secondoftwo
+ \or
+ \endgroup
+ \expandafter\ltx@firstoftwo
+ \else
+ \atfi@Warning{%
+ Internal error: Wrong pattern!\MessageBreak
+ --> #2 <--\MessageBreak
+ Pattern check ignored%
+ }%
+ \endgroup
+ \expandafter\ltx@firstoftwo
+ \fi
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@PatToken}
+% \begin{macrocode}
+ \def\atfi@PatToken{%
+ [%
+ -% first character
+ !%
+ \#$\%\&'%
+ \*\+\.%
+ 0-9%
+ A-Z%
+ \^_`%
+ a-z%
+ \{\}\|\~%
+ ]+%
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@CR}
+% \begin{macrocode}
+ \begingroup
+ \lccode64=13 % @
+ \lowercase{\endgroup
+ \def\atfi@CR{@}%
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@PatQuotedString}
+% \begin{macrocode}
+ \def\atfi@PatQuotedString{%
+ "%
+ ([^"\\\atfi@CR]|\\.)*%
+ "%
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+ \ltx@ifpackagelater{ltxcmds}{2010/09/11}{}{%
+% \end{macrocode}
+% \begin{macro}{\atfi@ltx@leftbracechar}
+% \begin{macrocode}
+ \begingroup
+ \lccode`0=`\{\relax
+ \lowercase{\endgroup
+ \def\ltx@leftbracechar{0}%
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ltx@rightbracechar}
+% \begin{macrocode}
+ \begingroup
+ \lccode`0=`\}\relax
+ \lowercase{\endgroup
+ \def\ltx@rightbracechar{0}%
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
}%
}
-\def\atfi@tohex#1{%
- \ifx\relax#1%
- \else
- \atfi@hexchar{#1}%
- \expandafter\atfi@tohex
- \fi
-}
-
-% --- convert to name ---
-
-\def\atfi@converttoname#1#2{%
- \edef#1{#2}%
- \@onelevel@sanitize#1%
- \edef#1{\expandafter\atfi@spacetoother#1 \relax}%
- \edef#1{\expandafter\atfi@converttokens#1\relax}%
+% \end{macrocode}
+%
+% \begin{macro}{\atfi@Warning}
+% \begin{macrocode}
+\def\atfi@Warning{\PackageWarning{attachfile2}}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Option declarations}
+%
+% \begin{macrocode}
+\SetupKeyvalOptions{%
+ family=AtFi,%
+ prefix=atfi@%
}
-
-\edef\atfi@hash{\string#}%
-\catcode`\ =12\relax%
-\def\atfi@space{ }%
-\catcode`\ =10\relax%
-
-\def\atfi@spacetoother#1 #2\relax{%
- #1%
- \ifx\\#2\\%
+% \end{macrocode}
+% \begin{macro}{\atfi@setup}
+% \begin{macrocode}
+\def\atfi@setup{\setkeys{AtFi}}
+% \end{macrocode}
+% \end{macro}
+%
+% Options \xoption{draft} and \xoption{final}.
+% \begin{macrocode}
+\DeclareBoolOption{draft}
+\DeclareComplementaryOption{final}{draft}
+% \end{macrocode}
+%
+% Option \xoption{mimetype}.
+% \begin{macro}{\atfi@mimetype}
+% \begin{macrocode}
+\def\atfi@mimetype{}
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\define@key{AtFi}{mimetype}{%
+ \edef\atfi@mimetype{#1}%
+ \ifx\atfi@mimetype\ltx@empty
\else
- \atfi@space
- \@ReturnAfterFi{%
- \atfi@spacetoother #2\relax
+ \atfi@Match\atfi@mimetype{%
+ ^(application|audio|image|model|text|video|x-\atfi@PatToken)%
+ /%
+ ([a-z\-\+_\.0-9]+)%
+ (; ?\atfi@PatToken=(\atfi@PatToken|\atfi@PatQuotedString))*$%
+ }{icase}{}{%
+ \atfi@Warning{%
+ Invalid value `\atfi@mimetype'\MessageBreak
+ of option `mimetype'.\MessageBreak
+ Value is discarded%
+ }%
+ \let\atfi@mimetype\ltx@empty
}%
\fi
-}
-\long\def\@ReturnAfterFi#1\fi{\fi#1}
-
-\def\atfi@converttokens#1{%
- \ifx\relax#1%
+ \ifx\atfi@mimetype\ltx@empty
\else
- \ifnum`#1<33 %
- \ifcase`#1%
- % drop illegal zero
- \else
- \atfi@hash\atfi@hexchar#1%
- \fi
- \else
- \ifnum`#1>126 %
- \atfi@hash\atfi@hexchar#1%
- \else
- \ifnum`#1=40 % (
- \atfi@hash 28%
- \else\ifnum`#1=41 % )
- \atfi@hash 29%
- \else\ifnum`#1=60 % <
- \atfi@hash 3c%
- \else\ifnum`#1=62 % >
- \atfi@hash 3e%
- \else\ifnum`#1=91 % [
- \atfi@hash 5b%
- \else\ifnum`#1=93 % ]
- \atfi@hash 5d%
- \else\ifnum`#1=123 % {
- \atfi@hash 7b%
- \else\ifnum`#1=125 % }
- \atfi@hash 7d%
- \else\ifnum`#1=47 % /
- \atfi@hash 2f%
- \else\ifnum`#1=37 % %
- \atfi@hash 25%
- \else
- #1%
- \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
- \fi
- \fi
- \expandafter\atfi@converttokens
+ \EdefEscapeName\atfi@mimetype{\atfi@mimetype}%
+ \edef\atfi@mimetype{/Subtype/\atfi@mimetype}%
\fi
}
-
-
-% --- options ---
-
-% options "draft" and "final"
-\newif\ifatfi@draft
-\let\atfi@finaltrue\atfi@draftfalse
-\let\atfi@finalfalse\atfi@drafttrue
-\define@key{AtFi}{final}[true]{%
- \csname atfi@final#1\endcsname
-}
-\define@key{AtFi}{draft}[true]{%
- \csname atfi@draft#1\endcsname
-}
-
-% option mimetype
-\def\atfi@mimetype{}
-\define@key{AtFi}{mimetype}{%
- \atfi@converttoname\atfi@mimetype{#1}%
- \edef\atfi@mimetype{/Subtype/\atfi@mimetype}%
-}
-
-% option icon
+% \end{macrocode}
+%
+% Option \xoption{icon}
+% \begin{macrocode}
\define@key{AtFi}{icon}{%
\def\atfi@icon{/Name/#1}%
\def\atfi@icon@icon{#1}%
}
-\setkeys{AtFi}{icon=PushPin}
-
-% option color
+\atfi@setup{icon=PushPin}
+% \end{macrocode}
+%
+% Option \xoption{color}
+% \begin{macrocode}
\define@key{AtFi}{color}{%
\HyColor@AttachfileColor{#1}%
\atfi@color@tex\atfi@color@inline\atfi@color@annot
{attachfile2}{color}%
}
-\setkeys{AtFi}{color=1 0.9255 0.7765}
-
-% time options timezone and date
+\atfi@setup{color=1 0.9255 0.7765}
+% \end{macrocode}
+%
+% time options timezone and date
+% \begin{macro}{\atfi@pad@ii}
+% \begin{macrocode}
\def\atfi@pad@ii#1{%
\ifnum#1>9 %
\number#1%
@@ -553,16 +631,42 @@ and the derived files
0\number#1%
\fi%
}
-\let\atfi@timezone\@empty
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{atfi@timezone}
+% \begin{macrocode}
+\let\atfi@timezone\ltx@empty
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
\define@key{AtFi}{timezone}{\def\atfi@timezone{#1}}
+% \end{macrocode}
+% \begin{macro}{\atfi@time}
+% \begin{macrocode}
\edef\atfi@time{\the\time}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@hours}
+% \begin{macrocode}
\def\atfi@hours{%
\numexpr\dimexpr0.01667\dimexpr\atfi@time sp\relax\relax\relax
}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@minutes}
+% \begin{macrocode}
\def\atfi@minutes{%
\numexpr\atfi@time-60*\atfi@hours\relax
}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@seconds}
+% \begin{macrocode}
\def\atfi@seconds{0}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@date}
+% \begin{macrocode}
\def\atfi@date{%
/M(D:\the\year
\atfi@pad@ii\month
@@ -572,124 +676,263 @@ and the derived files
\atfi@pad@ii\atfi@seconds
\atfi@timezone)%
}
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
\define@key{AtFi}{date}{%
\EdefEscapeString\atfi@date{#1}%
\edef\atfi@date{/M(\atfi@date)}%
}
-
-% name for annotation to be used in GoToE actions
-\let\atfi@annotname\@empty
-\define@key{AtFi}{annotname}{%
- \atfi@pdfstringdef\atfi@annotname{#1}%
- \edef\atfi@annotname{/NM(\atfi@annotname)}%
-}
-
-% text options author, description, and subject
+% \end{macrocode}
+%
+% Text options author, description, and subject
+% \begin{macro}{\atfi@pdfstringdef}
+% \begin{macrocode}
\DeclareRobustCommand{\atfi@pdfstringdef}[2]{%
\pdfstringdef\atfi@temp@string{#2}%
\edef#1{\atfi@temp@string}%
}
-
-% option author
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\atfi@NoValue}
+% \begin{macrocode}
+\def\atfi@NoValue{\NoValue}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\atfi@DefNoValueName}
+% \begin{macrocode}
+\def\atfi@DefNoValueName#1#2#3{%
+ \def#1{#3}%
+ \ifx#1\atfi@NoValue
+ \let#1\ltx@empty
+ \else
+ \atfi@pdfstringdef#1{#1}%
+ \edef#1{/#2(#1)}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Name for annotation to be used in GoToE actions
+% \begin{macro}{\atfi@annotname}
+% \begin{macrocode}
+\let\atfi@annotname\ltx@empty
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\define@key{AtFi}{annotname}[\NoValue]{%
+ \atfi@DefNoValueName\atfi@annotname{NM}{#1}%
+}
+% \end{macrocode}
+%
+% Option \xoption{author}.
+% \begin{macro}{\atfi@author}
+% \begin{macrocode}
\def\atfi@author{}
-\define@key{AtFi}{author}{%
- \atfi@pdfstringdef\atfi@author{#1}%
- \edef\atfi@author{/T(\atfi@author)}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\define@key{AtFi}{author}[\NoValue]{%
+ \atfi@DefNoValueName\atfi@author{T}{#1}%
}
-
-% option description
+% \end{macrocode}
+%
+% Option \xoption{description}.
+% \begin{macro}{\atfi@description}
+% \begin{macrocode}
\def\atfi@description{}
-\define@key{AtFi}{description}{%
- \atfi@pdfstringdef\atfi@description{#1}%
- \edef\atfi@description{/Contents(\atfi@description)}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\define@key{AtFi}{description}[\NoValue]{%
+ \atfi@DefNoValueName\atfi@description{Contents}{#1}%
}
-
-% option subject
+% \end{macrocode}
+%
+% Option \xoption{subject}.
+% \begin{macro}{\atfi@subject}
+% \begin{macrocode}
\def\atfi@subject{}
-\define@key{AtFi}{subject}{%
- \atfi@pdfstringdef\atfi@subject{#1}%
- \edef\atfi@subject{/Subj(\atfi@subject)}%
-}
-
-% option print
-\newif\ifatfi@print
-\atfi@printtrue
-\define@key{AtFi}{print}[true]{\csname atfi@print#1\endcsname}
-
-% option zoom
-\newif\ifatfi@zoom
-\atfi@zoomtrue
-\define@key{AtFi}{zoom}[true]{\csname atfi@zoom#1\endcsname}
-
-% option appearance
-\newif\ifatfi@appearance
-\atfi@appearancetrue
-\define@key{AtFi}{appearance}[true]{%
- \csname atfi@appearance#1\endcsname
-}
-
-% option scale
-\def\atfi@scale{1}
-\define@key{AtFi}{scale}[1]{%
- \def\atfi@scale{#1}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\define@key{AtFi}{subject}[\NoValue]{%
+ \atfi@DefNoValueName\atfi@subject{Subj}{#1}%
}
-
-% option ucfilespec
+% \end{macrocode}
+%
+% Option \xoption{print}.
+% \begin{macrocode}
+\DeclareBoolOption[true]{print}
+% \end{macrocode}
+%
+% Option \xoption{zoom}.
+% \begin{macrocode}
+\DeclareBoolOption[true]{zoom}
+% \end{macrocode}
+%
+% Option \xoption{appearance}.
+% \begin{macrocode}
+\DeclareBoolOption[true]{appearance}
+% \end{macrocode}
+%
+% Option \xoption{scale}.
+% \begin{macrocode}
+\DeclareStringOption[1]{scale}
+% \end{macrocode}
+%
+% Option \xoption{ucfilespec}.
+% \begin{macro}{\atfi@ucfilespec}
+% \begin{macrocode}
\def\atfi@ucfilespec{}
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
\define@key{AtFi}{ucfilespec}[1]{%
\def\atfi@ucfilespec{#1}%
- \ifx\atfi@ucfilespec\@empty
+ \ifx\atfi@ucfilespec\ltx@empty
\else
\atfi@pdfstringdef\atfi@ucfilespec{#1}%
\fi
}
-
-% option nofiles
-\newif\ifatfi@nofiles
-\atfi@nofilesfalse
-\define@key{AtFi}{nofiles}[true]{%
- \csname atfi@nofiles#1\endcsname
-}
-
-% driver options
-\let\atfi@driver\@empty
+% \end{macrocode}
+%
+% Option \xoption{nofiles}.
+% \begin{macrocode}
+\DeclareBoolOption{nofiles}
+% \end{macrocode}
+%
+% Driver options.
+% \begin{macrocode}
+\let\atfi@driver\ltx@empty
\def\atfi@driver@pdftex{pdftex}
\def\atfi@driver@dvips{dvips}
-
-\define@key{AtFi}{pdftex}[true]{%
+\def\atfi@driver@dvipdfmx{dvipdfmx}
+% \end{macrocode}
+% \begin{macrocode}
+\DeclareVoidOption{pdftex}{%
\let\atfi@driver\atfi@driver@pdftex
}
-\define@key{AtFi}{dvips}[true]{%
+\DeclareVoidOption{dvips}{%
\let\atfi@driver\atfi@driver@dvips
}
-
+\DeclareVoidOption{dvipdfmx}{%
+ \let\atfi@driver\atfi@driver@dvipdfmx
+}
+\DeclareVoidOption{xetex}{%
+ \let\atfi@driver\atfi@driver@dvipdfmx
+}
+% \end{macrocode}
+% \begin{macrocode}
+\DeclareStringOption{driverfallback}
+% \end{macrocode}
+%
+% \begin{macro}{\attachfilesetup}
+% \begin{macrocode}
\DeclareRobustCommand{\attachfilesetup}[1]{\setkeys{AtFi}{#1}}
-
-% timezone setting, ...
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\DeclareLocalOptions{%
+ annotname,%
+ appearance,%
+ author,%
+ color,%
+ date,%
+ description,%
+ icon,%
+ mimetype,%
+ nofiles,%
+ print,%
+ scale,%
+ subject,%
+ timezone,%
+ ucfilespec,%
+ zoom,%
+}
+% \end{macrocode}
+%
+% \subsubsection{Option calling}
+%
+% Timezone setting, \dots
+% \begin{macrocode}
\InputIfFileExists{attachfile.cfg}{}{}
-
-\ProcessKeyvalOptions{AtFi}
-
-% --- evaluate driver options ---
-
+% \end{macrocode}
+% \begin{macrocode}
+\ProcessKeyvalOptions*
+% \end{macrocode}
+%
+% \begin{macro}{\atfi@DisableOption}
+% \begin{macrocode}
+\def\atfi@DisableOption{%
+ \DisableKeyvalOption[action=error,package=attachfile2]{AtFi}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Evaluate driver options}
+%
+% \begin{macrocode}
\ifpdf
% ignoring other driver options
\let\atfi@driver\atfi@driver@pdftex
\else
- \ifx\atfi@driver\@empty
- \PackageWarningNoLine{attachfile2}{%
- Driver is not specified,\MessageBreak
- enforce draft settings%
- }%
- \atfi@drafttrue
+ \ifx\atfi@driver\atfi@driver@pdftex
+ \let\atfi@driver\ltx@empty
+ \PackageError{attachfile2}{%
+ Wrong driver option `pdftex',\MessageBreak
+ because pdfTeX in PDF mode is not detected%
+ }\@ehc
+ \fi
+ \ifxetex
+ \let\atfi@driver\atfi@driver@dvipdfmx
+ \else
+ \ifx\atfi@driver\ltx@empty
+ \ifx\atfi@driverfallback\ltx@empty
+ \else
+ \expandafter\let\expandafter\atfi@driver
+ \csname atfi@driver@\atfi@driverfallback\endcsname
+ \ifx\atfi@driver\atfi@driver@dvips
+ \else
+ \ifx\atfi@driver\atfi@driver@dvipdfmx
+ \else
+ \let\atfi@driver\ltx@empty
+ \PackageWarningNoLine{attachfile2}{%
+ Option `driverfallback' with unsupported\MessageBreak
+ DVI driver (\atfi@driverfallback)%
+ }%
+ \fi
+ \fi
+ \fi
+ \ifx\atfi@driver\ltx@empty
+ \PackageWarningNoLine{attachfile2}{%
+ Driver is not specified,\MessageBreak
+ enforce draft settings%
+ }%
+ \atfi@drafttrue
+ \fi
+ \fi
\fi
\fi
-
-% --- evaluate draft/final options ---
-
+% \end{macrocode}
+% \begin{macrocode}
+\atfi@DisableOption{pdftex}
+\atfi@DisableOption{dvips}
+\atfi@DisableOption{dvipdfmx}
+\atfi@DisableOption{xetex}
+\atfi@DisableOption{driverfallback}
+% \end{macrocode}
+%
+% \subsubsection{Evaluate options \xoption{draft}/\xoption{final}}
+%
+% \begin{macro}{\notextattachfile}
+% \begin{macrocode}
\DeclareRobustCommand{\notextattachfile}[2][]{%
\begingroup
- \setkeys{AtFi}{#1}%
+ \atfi@setup{#1}%
\ifatfi@print
\leavevmode
\begingroup
@@ -697,12 +940,16 @@ and the derived files
#2\strut
\endgroup
\else
- \setbox0=\hbox{#2\strut}%
+ \sbox\ltx@zero{#2\strut}%
\makebox[\wd0]{}%
\fi
\endgroup
}
-
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\atfi@DisableOption{draft}%
+\atfi@DisableOption{final}%
\ifatfi@draft
\def\atfi@dummy@pushpin{%
\raisebox{-1.25bp}{\parbox[b][14bp]{24bp}{}}%
@@ -716,15 +963,20 @@ and the derived files
\DeclareRobustCommand{\attachfile}[2][]{%
\noattachfile[{#1}]%
}%
- \expandafter\endinput
+ \expandafter\endinput
\fi
-
-% --- load driver file ---
-
-\input{atfi\atfi@driver.def}
-
-% --- graphics ---
-
+% \end{macrocode}
+%
+% \subsubsection{Load driver file}
+%
+% \begin{macrocode}
+\input{atfi-\atfi@driver.def}
+% \end{macrocode}
+%
+% \subsubsection{Graphics}
+%
+% \begin{macro}{\atfi@acroGraph@data}
+% \begin{macrocode}
\def\atfi@acroGraph@data{%
\atfi@GSAVE
0.5 \atfi@SETGRAYFILL
@@ -749,11 +1001,19 @@ and the derived files
13.7041 3.0938 3.9571 11.8867 \atfi@RECTFILL
\atfi@GRESTORE
}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@acroGraph}
+% \begin{macrocode}
\def\atfi@acroGraph{%
\raisebox{-1.5bp}{\parbox[b][20bp]{22bp}{%
\rule{0pt}{0pt}\atfi@literal{\atfi@acroGraph@data}}%
}%
}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@acroPaperclip@data}
+% \begin{macrocode}
\newcommand{\atfi@acroPaperclip@data}{%
\atfi@GSAVE
0.75 \atfi@SETGRAYSTROKE
@@ -811,11 +1071,19 @@ and the derived files
\atfi@STROKE
\atfi@GRESTORE
}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@acroPaperclip}
+% \begin{macrocode}
\def\atfi@acroPaperclip{%
\raisebox{-1.25bp}{\parbox[b][21bp]{12bp}{%
\rule{0pt}{0pt}\atfi@literal{\atfi@acroPaperclip@data}}%
}%
}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@acroPushPin@data}
+% \begin{macrocode}
\def\atfi@acroPushPin@data{%
\atfi@GSAVE
1 \atfi@SETLINEWIDTH
@@ -853,11 +1121,19 @@ and the derived files
\atfi@STROKE
\atfi@GRESTORE
}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@acroPushPin}
+% \begin{macrocode}
\def\atfi@acroPushPin{%
\raisebox{-1.25bp}{\parbox[b][14bp]{24bp}{%
\rule{0pt}{0pt}\atfi@literal{\atfi@acroPushPin@data}}%
}%
}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@acroTag@data}
+% \begin{macrocode}
\def\atfi@acroTag@data{%
\atfi@GSAVE
0.5 \atfi@SETGRAYFILL
@@ -923,23 +1199,37 @@ and the derived files
\atfi@STROKE
\atfi@GRESTORE
}
-\DeclareRobustCommand{\atfi@acroTag}{%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@acroTag}
+% \begin{macrocode}
+\def\atfi@acroTag{%
\raisebox{-1.6bp}{\parbox[b][17bp]{25bp}{%
\rule{0pt}{0pt}\atfi@literal{\atfi@acroTag@data}}%
}%
}
-
-% --- .atfi file reading support ---
-
-% commands used in \jobname.atfi:
-% * \attachfile@timezone{<timezone in PDF format>}
-% * \attachfile@file[
-% Size=<size>,
-% CreationDate=<date>, % <date> local time without "D:" and timezone
-% ModDate=<date>,
-% CheckSum=<checksum>
-% ]{<filename as hex string>}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Reading the \xext{atfi} file}
%
+% Commands used in \cs{jobname}\xext{atfi}:
+% \begin{itemize}
+% \item |attachfile@timezone{<timezone in PDF format>}|
+% \item
+%\begin{verbatim}
+%\attachfile@file[
+% Size=<size>,
+% CreationDate=<date>, % <date> local time without "D:" and timezone
+% ModDateTZ=<date+TZ>,
+% ModDate=<date>,
+% CheckSum=<checksum>
+%]{<filename as hex string>}
+%\end{verbatim}
+% \end{itemize}
+%
+% \begin{macro}{\attachfile@timezone}
+% \begin{macrocode}
\def\attachfile@timezone#1{%
\ifx\\#1\\%
% no timezone information given
@@ -947,63 +1237,124 @@ and the derived files
\def\atfi@timezone{#1}%
\fi
}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\attachfile@file}
+% \begin{macrocode}
\newcommand*{\attachfile@file}[2][]{%
- \ifx\\#2\\%
+ \EdefUnescapeHex\atfi@filename{#2}%
+ \ifx\atfi@filename\ltx@empty
\PackageError{attachfile2}{Empty file name}\@ehc
\else
- \edef\atfi@restore{\uccode0=\the\uccode0 \relax}%
- \let\atfi@filename\@empty
- \atfi@getfilename#2\relax\relax
- \atfi@restore
\@namedef{atfi@file@\atfi@filename}{#1}%
\fi
}
-% convert file name from hex string
-\begingroup
- \catcode0=12 %
- \gdef\atfi@getfilename#1#2{%
- \ifx\relax#1%
- \else
- \uccode0=\numexpr 16*\atfi@hexnum{#1} + \atfi@hexnum{#2}\relax
- \uppercase{%
- \edef\atfi@filename{%
- \atfi@filename^^@%
- }%
- }%
- \expandafter\atfi@getfilename
- \fi
- }%
-\endgroup
-\def\atfi@hexnum#1{%
- \ifnum`#1<58 %
- \numexpr `#1-48\relax
- \else
- \numexpr `#1-87\relax
- \fi
-}
-
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
\InputIfFileExists{\jobname.atfi}{}{}%
-
+% \end{macrocode}
+%
+% \begin{macrocode}
\newif\ifatfi@checksum
\define@key{AtFi@file}{CheckSum}{%
\atfi@checksumtrue
\edef\atfi@params{\atfi@params/CheckSum<#1>}%
}
+% \end{macrocode}
+% \begin{macrocode}
\newif\ifatfi@creationdate
+\define@key{AtFi@file}{CreationDateTZ}{%
+ \ifatfi@creationdate
+ \else
+ \atfi@creationdatetrue
+ \edef\atfi@params{%
+ \atfi@params
+ /CreationDate(#1)%
+ }%
+ \fi
+}
+% \end{macrocode}
+% \begin{macrocode}
\define@key{AtFi@file}{CreationDate}{%
- \atfi@creationdatetrue
- \edef\atfi@params{\atfi@params/CreationDate(D:#1\atfi@timezone)}%
+ \ifatfi@creationdate
+ \else
+ \atfi@creationdatetrue
+ \edef\atfi@params{%
+ \atfi@params
+ /CreationDate(#1\atfi@timezone)%
+ }%
+ \fi
}
+% \end{macrocode}
+% \begin{macrocode}
\newif\ifatfi@moddate
+\define@key{AtFi@file}{ModDateTZ}{%
+ \ifatfi@moddate
+ \else
+ \atfi@moddatetrue
+ \edef\atfi@params{%
+ \atfi@params
+ /ModDate(#1)%
+ }%
+ \fi
+}
+% \end{macrocode}
+% \begin{macrocode}
\define@key{AtFi@file}{ModDate}{%
- \atfi@moddatetrue
- \edef\atfi@params{\atfi@params/ModDate(D:#1\atfi@timezone)}%
+ \ifatfi@moddate
+ \else
+ \atfi@moddatetrue
+ \edef\atfi@params{%
+ \atfi@params
+ /ModDate(D:#1\atfi@timezone)%
+ }%
+ \fi
}
-
-% --- .atfi file writing support ---
-
-% respect \nofiles and option nofiles
-% \nofiles has more weight than option nofiles
+% \end{macrocode}
+%
+% \begin{macro}{\atfi@pdftexdata}
+% \begin{macrocode}
+\let\atfi@temp\ltx@one
+\ltx@IfUndefined{pdf@filesize}{%
+ \let\atfi@temp\ltx@zero
+}{}
+\ltx@IfUndefined{pdf@filemoddate}{%
+ \let\atfi@temp\ltx@zero
+}{}
+\ltx@IfUndefined{pdf@filemdfivesum}{%
+ \let\atfi@temp\ltx@zero
+}{}
+\ifcase\atfi@temp
+ \let\atfi@pdftexdata\ltx@gobble
+\or
+ \def\atfi@pdftexdata#1{%
+ \edef\atfi@temp{\pdf@filesize{#1}}%
+ \ifx\atfi@temp\ltx@empty
+ \else
+ \setkeys{AtFi@file}{Size=\atfi@temp}%
+ \edef\atfi@temp{\pdf@filemoddate{#1}}%
+ \ifx\atfi@temp\ltx@empty
+ \else
+ \setkeys{AtFi@file}{ModDateTZ=\atfi@temp}%
+ \fi
+ \edef\atfi@temp{\pdf@filemdfivesum{#1}}%
+ \ifx\atfi@temp\ltx@empty
+ \else
+ \setkeys{AtFi@file}{CheckSum=\atfi@temp}%
+ \fi
+ \fi
+ }%
+\fi
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Writing the \xext{atfi} file}
+%
+% Respect \cs{nofiles} and option \xoption{nofiles}.
+% \cs{nofiles} has more weight than option \xoption{nofiles}.
+% \begin{macrocode}
\if@filesw
\else
\atfi@nofilestrue
@@ -1013,89 +1364,126 @@ and the derived files
File `\jobname.atfi' will not be written because of\MessageBreak
\string\nofiles\space or option `nofiles'%
}%
- \let\atfi@writefile\@gobble
+% \end{macrocode}
+% \begin{macro}{\atfi@writefile}
+% \begin{macrocode}
+ \let\atfi@writefile\ltx@gobble
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
\else
+% \end{macrocode}
+% \begin{macro}{\atfi@stream}
+% \begin{macrocode}
\newwrite\atfi@stream
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
\immediate\openout\atfi@stream=\jobname.atfi\relax
\immediate\write\atfi@stream{%
\string\attachfile@timezone{\atfi@timezone}%
}%
+% \end{macrocode}
+% \begin{macro}{\atfi@writefile}
+% \begin{macrocode}
\def\atfi@writefile#1{%
\begingroup
- \def\file{#1}%
- \@onelevel@sanitize\file
- \edef\file{\@firstofone{\expandafter\atfi@replace\file} \@nil}%
- \edef\file{\expandafter\atfi@tohex\file\relax}%
+ \EdefEscapeHex\atfi@temp{#1}%
\immediate\write\atfi@stream{%
\string\attachfile@file[%
- \@ifundefined{atfi@file@#1}{}{\@nameuse{atfi@file@#1}}%
- ]{\file}%
+ \ltx@ifundefined{atfi@file@#1}{}{\@nameuse{atfi@file@#1}}%
+ ]{\atfi@temp}%
}%
\endgroup
}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
\fi
-
+\atfi@DisableOption{nofiles}
+% \end{macrocode}
+%
+% \begin{macro}{\atfi@attachfile}
+% \begin{macrocode}
\def\atfi@attachfile#1#2{%
- \@ifundefined{atfi@fileobj@#2}{%
+ \ltx@IfUndefined{atfi@fileobj@#2}{%
\atfi@writefile{#2}%
}{%
% don't need duplicates
}%
- \setkeys{AtFi}{#1}%
+ \atfi@setup{#1}%
\atfi@embedfile{#2}%
\atfi@set@appearance@icon
\atfi@flags@to@int
\atfi@insert@file@annot{#2}%
\endgroup
}
-
-% convert to hex string
-
-\def\atfi@replace#1 #2\@nil{%
- #1%
- \ifx\\#2\\%
- \else
- \atfi@space
- \@ReturnAfterFi{%
- \atfi@replace#2\@nil
- }%
- \fi
-}%
-
-\long\def\@ReturnAfterFi#1\fi{\fi#1}
-
-% ---
-
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Annotation appearance}
+%
+% \begin{macro}{\atfi@appearancewidth}
+% \begin{macrocode}
\newlength{\atfi@appearancewidth}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@appearanceheight}
+% \begin{macrocode}
\newlength{\atfi@appearanceheight}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@appearancedepth}
+% \begin{macrocode}
\newlength{\atfi@appearancedepth}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@appearancebox}
+% \begin{macrocode}
\newsavebox{\atfi@appearancebox}
-
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\atfi@set@appearance@icon}
+% \begin{macrocode}
\def\atfi@set@appearance@icon{%
- \@ifundefined{atfi@appobj@\atfi@icon@icon}{%
- \savebox{\atfi@appearancebox}{\@nameuse{atfi@acro\atfi@icon@icon}}%
- \expandafter\xdef\csname atfi@appwidth@\atfi@icon@icon\endcsname{%
+ \ltx@IfUndefined{atfi@appobj@\atfi@icon@icon}{%
+ \savebox{\atfi@appearancebox}{%
+ \@nameuse{atfi@acro\atfi@icon@icon}%
+ }%
+ \expandafter
+ \xdef\csname atfi@appwidth@\atfi@icon@icon\endcsname{%
\the\wd\atfi@appearancebox
}%
- \expandafter\xdef\csname atfi@appheight@\atfi@icon@icon\endcsname{%
+ \expandafter
+ \xdef\csname atfi@appheight@\atfi@icon@icon\endcsname{%
\the\ht\atfi@appearancebox
}%
- \expandafter\xdef\csname atfi@appdepth@\atfi@icon@icon\endcsname{%
+ \expandafter
+ \xdef\csname atfi@appdepth@\atfi@icon@icon\endcsname{%
\the\dp\atfi@appearancebox
}%
\atfi@xform@icon
- \global\expandafter\let\csname atfi@appobj@\atfi@icon@icon\endcsname
+ \global\expandafter\let
+ \csname atfi@appobj@\atfi@icon@icon\endcsname
\atfi@appearanceobj
}{%
}%
% optimization: \setlength dropped
- \atfi@appearancewidth=\@nameuse{atfi@appwidth@\atfi@icon@icon}\relax
- \atfi@appearanceheight=\@nameuse{atfi@appheight@\atfi@icon@icon}\relax
- \atfi@appearancedepth=\@nameuse{atfi@appdepth@\atfi@icon@icon}\relax
+ \atfi@appearancewidth=%
+ \@nameuse{atfi@appwidth@\atfi@icon@icon}\relax
+ \atfi@appearanceheight=%
+ \@nameuse{atfi@appheight@\atfi@icon@icon}\relax
+ \atfi@appearancedepth=%
+ \@nameuse{atfi@appdepth@\atfi@icon@icon}\relax
\expandafter\let\expandafter\atfi@appearanceobj
\csname atfi@appobj@\atfi@icon@icon\endcsname
}
-
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\atfi@set@appearance}
+% \begin{macrocode}
\def\atfi@set@appearance#1{%
\savebox{\atfi@appearancebox}{#1}%
\atfi@appearancewidth=\wd\atfi@appearancebox
@@ -1103,8 +1491,14 @@ and the derived files
\atfi@appearancedepth=\dp\atfi@appearancebox
\atfi@xform
}
-
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
\newcounter{atfi@flags}
+% \end{macrocode}
+% \begin{macro}{\atfi@flags@to@int}
+% \begin{macrocode}
\DeclareRobustCommand{\atfi@flags@to@int}{%
\setcounter{atfi@flags}{0}%
\ifatfi@print
@@ -1115,13 +1509,26 @@ and the derived files
\addtocounter{atfi@flags}{8}%
\fi%
}
-
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\atfi@textattachfile}
+% \begin{macrocode}
\def\atfi@textattachfile#1#2{%
\endgroup
\atfi@textattachfile@i{#1}{#2}%
}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@textattachfile@i}
+% \begin{macrocode}
\def\atfi@textattachfile@i#1#2#3{%
- \setkeys{AtFi}{#1}%
+ \ltx@IfUndefined{atfi@fileobj@#2}{%
+ \atfi@writefile{#2}%
+ }{%
+ % don't need duplicates
+ }%
+ \atfi@setup{#1}%
\atfi@embedfile{#2}%
\atfi@set@appearance{%
\leavevmode
@@ -1134,7 +1541,11 @@ and the derived files
\atfi@insert@file@annot{#2}%
\endgroup
}
-
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\attachfile}
+% \begin{macrocode}
\DeclareRobustCommand{\attachfile}[1][]{%
\begingroup
\let\do\@makeother
@@ -1143,6 +1554,10 @@ and the derived files
\catcode`\}=2\relax
\atfi@attachfile{#1}%
}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\textattachfile}
+% \begin{macrocode}
\DeclareRobustCommand{\textattachfile}[1][]{%
\begingroup
\begingroup
@@ -1152,18 +1567,25 @@ and the derived files
\catcode`\}=2\relax
\atfi@textattachfile{#1}%
}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\noattachfile}
+% \begin{macrocode}
\DeclareRobustCommand{\noattachfile}[1][]{%
\begingroup
- \setkeys{AtFi}{#1}%
+ \atfi@setup{#1}%
\atfi@set@appearance@icon
\ifatfi@print
- \expandafter\atfi@refxform\csname atfi@appobj@\atfi@icon@icon\endcsname
+ \expandafter
+ \atfi@refxform\csname atfi@appobj@\atfi@icon@icon\endcsname
\else
\makebox[\atfi@appearancewidth]{}%
\fi
\endgroup
}
% \end{macrocode}
+% \end{macro}
+%
% \begin{macrocode}
%</package>
% \end{macrocode}
@@ -1175,14 +1597,56 @@ and the derived files
% \begin{macrocode}
%<*pdftex>
\NeedsTeXFormat{LaTeX2e}
-\ProvidesFile{atfipdftex.def}%
- [2009/09/25 v2.5 attachfile2 driver for pdfTeX (HO)]%
+\ProvidesFile{atfi-pdftex.def}%
+ [2010/09/27 v2.6 attachfile2 driver for pdfTeX (HO)]%
% \end{macrocode}
+%
+% \paragraph{\LuaTeX}
+%
+% \begin{macrocode}
+\ifluatex
+ \ifnum\luatexversion<39 %
+ \else
+ \begingroup
+ \escapechar=-1 %
+ \def\atfi@temp#1{%
+ \ltx@IfUndefined{\string#1}{%
+ \let#1\ltx@undefined
+ \directlua{%
+ if tex.enableprimitives then %
+ tex.enableprimitives('', {'\string#1'})%
+ end%
+ }%
+ \ltx@ifundefined{\string#1}{%
+ }{%
+ \global#1=#1%
+ \@PackageInfoNoLine{attachfile2}{%
+ \string#1 enabled%
+ }%
+ }%
+ }{}%
+ }%
+ \atfi@temp\pdfliteral
+ \atfi@temp\pdfobj
+ \atfi@temp\pdflastobj
+ \atfi@temp\pdfxform
+ \atfi@temp\pdflastxform
+ \atfi@temp\pdfrefxform
+ \atfi@temp\pdfannot
+ \endgroup
+ \fi
+\fi
+% \end{macrocode}
+%
+% \paragraph{Macros for graphics data}
+%
+% \begin{macro}{\atfi@literal}
% \begin{macrocode}
\let\atfi@literal\pdfliteral
-
-% --- macros for graphics data ---
-
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
\def\atfi@GSAVE{q }
\def\atfi@GRESTORE{Q }
\def\atfi@SETLINEWIDTH{w }
@@ -1192,8 +1656,10 @@ and the derived files
\def\atfi@FILL{f }
% \atfi@FILLSTROKE{<fill color>}{<stroke color>}
\def\atfi@FILLSTROKE#1#2{#1#2B }
+% \end{macrocode}
% color: uppercase are stroke colors, lowercase non-stroke (fill) colors
% PS, however, does not different between stroke and not-stroke colors
+% \begin{macrocode}
\def\atfi@SETRGBCOLORSTROKE{RG }
\def\atfi@SETRGBCOLORFILL{rg }
\def\atfi@SETGRAYSTROKE{G }
@@ -1210,22 +1676,35 @@ and the derived files
\def\atfi@CURVETOY{y }
\def\atfi@CLOSEPATH{h }
\def\atfi@SETLINEJOIN{j }
-
-% ---
-
+% \end{macrocode}
+%
+% \paragraph{File embedding}
+%
+% \begin{macrocode}
\define@key{AtFi@file}{Size}{%
\edef\atfi@params{\atfi@params/Size #1}%
}
-
+% \end{macrocode}
+% \begin{macro}{\atfi@embedfile}
+% \begin{macrocode}
\def\atfi@embedfile#1{%
- \@ifundefined{atfi@fileobj@#1}{%
+ \ltx@IfUndefined{atfi@fileobj@#1}{%
\begingroup
- \let\atfi@params\@empty
- \@ifundefined{atfi@file@#1}{}{%
- \edef\x{\noexpand\setkeys{AtFi@file}{\@nameuse{atfi@file@#1}}}%
+ \let\atfi@params\ltx@empty
+ \expandafter\let\expandafter\atfi@temp
+ \csname atfi@file@#1\endcsname
+ \ifx\atfi@temp\ltx@empty
+ \let\atfi@temp\relax
+ \fi
+ \ifx\atfi@temp\relax
+ \atfi@pdftexdata{#1}%
+ \else
+ \edef\x{%
+ \noexpand\setkeys{AtFi@file}{\@nameuse{atfi@file@#1}}%
+ }%
\x
- }%
- \ifx\atfi@params\@empty
+ \fi
+ \ifx\atfi@params\ltx@empty
\else
\edef\atfi@params{/Params<<\atfi@params>>}%
\fi
@@ -1234,28 +1713,45 @@ and the derived files
\atfi@mimetype
\atfi@params
} file {#1}%
- \expandafter\xdef\csname atfi@fileobj@#1\endcsname{\the\pdflastobj}%
+ \expandafter
+ \xdef\csname atfi@fileobj@#1\endcsname{\the\pdflastobj}%
\endgroup
}{%
% file already embedded
}%
}
-
-% ---
-
-% input: \atfi@appearancebox, output: \atfi@appearanceobj
+% \end{macrocode}
+% \end{macro}
+%
+% \paragraph{Annotation appearance}
+%
+% \begin{macro}{\atfi@xform}
+% input: \cs{atfi@appearancebox}, output: \cs{atfi@appearanceobj}
+% \begin{macrocode}
\def\atfi@xform{%
\immediate\pdfxform\atfi@appearancebox
\edef\atfi@appearanceobj{\the\pdflastxform}%
}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@xform@icon}
+% \begin{macrocode}
\let\atfi@xform@icon\atfi@xform
-
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\atfi@refxform}
+% \begin{macrocode}
\def\atfi@refxform#1{%
\pdfrefxform#1\relax
}
-
-% ---
-
+% \end{macrocode}
+% \end{macro}
+%
+% \paragraph{File attachment annotation}
+%
+% \begin{macro}{\atfi@insert@file@annot}
+% \begin{macrocode}
\def\atfi@insert@file@annot#1{%
\rule{0pt}{0pt}%
\ifatfi@appearance
@@ -1267,9 +1763,9 @@ and the derived files
>>%
}%
\else
- \let\atfi@appearance@dict\@empty
+ \let\atfi@appearance@dict\ltx@empty
\fi
- \@ifundefined{atfi@fsobj@#1}{%
+ \ltx@IfUndefined{atfi@fsobj@#1}{%
\begingroup
\hypersetup{unicode=false}%
\atfi@pdfstringdef\atfi@file{#1}%
@@ -1277,7 +1773,7 @@ and the derived files
<<%
/Type/Filespec%
/F(\atfi@file)%
- \ifx\atfi@ucfilespec\@empty
+ \ifx\atfi@ucfilespec\ltx@empty
\else
/UF(\atfi@ucfilespec)%
\fi
@@ -1312,6 +1808,8 @@ and the derived files
\rule{\atfi@appearancewidth}{0pt}%
}
% \end{macrocode}
+% \end{macro}
+%
% \begin{macrocode}
%</pdftex>
% \end{macrocode}
@@ -1321,20 +1819,28 @@ and the derived files
% \begin{macrocode}
%<*dvips>
\NeedsTeXFormat{LaTeX2e}
-\ProvidesFile{atfipdftex.def}%
- [2009/09/25 v2.5 attachfile2 driver for dvips (HO)]%
+\ProvidesFile{atfi-dvips.def}%
+ [2010/09/27 v2.6 attachfile2 driver for dvips (HO)]%
% \end{macrocode}
+%
+% \paragraph{Macros for graphics data}
+%
+% \begin{macro}{\atfi@literal}
% \begin{macrocode}
\def\atfi@literal#1{%
\special{ps:atfi_dict begin{#1}atfi_?pdfmark end}%
}
-
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@header}
+% \begin{macrocode}
\def\atfi@header#1{%
\special{! #1}%
}
-
-% --- macros for graphics data ---
-
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
\atfi@header{%
userdict begin 20 dict dup /atfi_dict exch def end begin%
/atfi_?pdfmark systemdict %
@@ -1525,7 +2031,8 @@ and the derived files
} atfi_?pdfmark %
end%
}
-
+% \end{macrocode}
+% \begin{macrocode}
\def\atfi@GSAVE{gsave }
\def\atfi@GRESTORE{grestore }
\def\atfi@SETLINEWIDTH{setlinewidth }
@@ -1558,62 +2065,83 @@ and the derived files
\def\atfi@CURVETOY{atfi_curveto_y }
\def\atfi@CLOSEPATH{closepath }
\def\atfi@SETLINEJOIN{setlinejoin }
-
-% ---
-
+% \end{macrocode}
+%
+% \begin{macrocode}
\newcounter{atfi@obj}
\renewcommand*{\theatfi@obj}{%
{atfi_obj_\number\c@atfi@obj}%
}
-
-
-% most values for Params dictionary found in the .atfi file have
-% priority:
-% * Recalculation (md5sum, ...) is avoided.
-% * An external script has more possibilities than programming
-% at PostScript level (operating system, getting the date and
-% time values of the file with correct interpretation.
-% * Exception: status is called to test file existence, thus
-% we get the value of size for free
-
+% \end{macrocode}
+%
+% \paragraph{File embedding}
+%
+% Most values for Params dictionary found in the \xext{atfi} file
+% have priority:
+% \begin{itemize}
+% \item Recalculation (md5sum, \dots) is avoided.
+% \item An external script has more possibilities than programming
+% at PostScript level (operating system, getting the date and
+% time values of the file with correct interpretation.
+% \item Exception: status is called to test file existence, thus
+% we get the value of size for free.
+% \end{itemize}
+% \begin{macrocode}
\define@key{AtFi@file}{Size}{}
-
+% \end{macrocode}
+% \begin{macro}{\atfi@embedfile}
+% \begin{macrocode}
\def\atfi@embedfile#1{%
- \@ifundefined{atfi@fileobj@#1}{%
+ \ltx@IfUndefined{atfi@fileobj@#1}{%
\atfi@pdfstringdef\atfi@psfilename{#1}%
\stepcounter{atfi@obj}%
\expandafter\xdef\csname atfi@fileobj@#1\endcsname{\theatfi@obj}%
\begingroup
- \let\atfi@params\@empty
- \@ifundefined{atfi@file@#1}{}{%
- \edef\x{\noexpand\setkeys{AtFi@file}{\@nameuse{atfi@file@#1}}}%
+ \let\atfi@params\ltx@empty
+ \expandafter\let\expandafter\atfi@temp
+ \csname atfi@file@#1\endcsname
+ \ifx\atfi@temp\ltx@empty
+ \let\atfi@temp\relax
+ \fi
+ \ifx\atfi@temp\relax
+ \atfi@pdftexdata{#1}%
+ \else
+ \edef\x{%
+ \noexpand\setkeys{AtFi@file}{\@nameuse{atfi@file@#1}}%
+ }%
\x
- }%
+ \fi
\atfi@literal{%
/atfi_filename(\atfi@psfilename)def %
atfi_filename status%
{%
- % ok: file found
- % save parameters of status command
+% \end{macrocode}
+% ok: file found\\
+% save parameters of status command
+% \begin{macrocode}
/atfi_created exch def%
/atfi_referenced exch def%
/atfi_size exch def %
- pop % drop parameter "pages" (storage space), never needed
- % ghostscript:
- % created: stat.st_ctime
- % referenced: stat.st_mtime
- % stat.st_ctime: interpretion depends on operating system:
- % * unix: inode change time (not interesting)
- % * win32: probably creation time
- % --> /CreationDate
- % stat.st_mtime: modification time --> /ModDate
- % time values are seconds since 1970-01-01, GMT
- % TODO: ghostscript offers "getenv" for getting the value
- % of an environment variable. That could be used to
- % to detect windows and settingthe /CreationDate entry.
- % TODO: how are these values interpreted by other distiller
- % programs?
- %
+ pop %
+% \end{macrocode}
+%\begin{verbatim}
+%drop parameter "pages" (storage space), never needed
+%ghostscript:
+% created: stat.st_ctime
+% referenced: stat.st_mtime
+% stat.st_ctime: interpretion depends on operating system:
+% * unix: inode change time (not interesting)
+% * win32: probably creation time
+% --> /CreationDate
+% stat.st_mtime: modification time --> /ModDate
+% time values are seconds since 1970-01-01, GMT
+%TODO: ghostscript offers "getenv" for getting the value
+% of an environment variable. That could be used to
+% to detect windows and settingthe /CreationDate entry.
+%TODO: how are these values interpreted by other distiller
+% programs?
+%\end{verbatim}
+% \begin{macrocode}
[%
/_objdef \theatfi@obj
/type/stream%
@@ -1632,12 +2160,15 @@ and the derived files
/product where%
{%
pop %
- % check for ghostscript
+% \end{macrocode}
+% check for ghostscript
+% \begin{macrocode}
product (Ghostscript) search%
{%
pop pop pop %
- % ghostscript is running
- %
+% \end{macrocode}
+% ghostscript is running
+% \begin{macrocode}
\ifatfi@creationdate
\else
false % TODO: test for windows
@@ -1650,8 +2181,9 @@ and the derived files
/ModDate atfi_referenced atfi_convert_date%
\fi
} if%
- %
- % look for MD5Encode filter and calculate CheckSum
+% \end{macrocode}
+% look for MD5Encode filter and calculate CheckSum
+% \begin{macrocode}
} if %
\ifatfi@checksum
\else
@@ -1668,20 +2200,29 @@ and the derived files
\theatfi@obj
/CLOSE pdfmark%
}{%
- % error: file not found
- % currently nothing is done
+% \end{macrocode}
+% error: file not found\\
+% currently nothing is done
+% \begin{macrocode}
} ifelse%
}%
\endgroup
}{%
- % file already embedded
+% \end{macrocode}
+% file already embedded
+% \begin{macrocode}
}%
}
-
-% ---
-
-% output: \atfi@appearanceobj
-% input: \atfi@appearancebox, \atfi@icon@icon
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \paragraph{Annotation appearance}
+%
+% output: \cs{atfi@appearanceobj}\\
+% input: \cs{atfi@appearancebox}, \cs{atfi@icon@icon}
+% \begin{macro}{atfi@xfrom@icon}
+% \begin{macrocode}
\def\atfi@xform@icon{%
\stepcounter{atfi@obj}%
\edef\atfi@appearanceobj{\theatfi@obj}%
@@ -1701,13 +2242,17 @@ and the derived files
/EP pdfmark%
}%
}
-% output: \atfi@appearanceobj
-% input: \atfi@appearancebox
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@xform}
+% output: \cs{atfi@appearanceobj},
+% input: \cs{atfi@appearancebox}
+% \begin{macrocode}
\def\atfi@xform{%
\stepcounter{atfi@obj}%
\edef\atfi@appearanceobj{\theatfi@obj}%
\begingroup
- \setbox0=\hbox{%
+ \setbox\ltx@zero=\hbox{%
\atfi@literal{%
[%
/_objdef \atfi@appearanceobj
@@ -1733,13 +2278,16 @@ and the derived files
}%
}%
% do not allocate any space for xobject definition
- \dp0=\z@
- \ht0=\z@
- \wd0=\z@
- \mbox{\usebox0}%
+ \dp\ltx@zero=\z@
+ \ht\ltx@zero=\z@
+ \wd\ltx@zero=\z@
+ \mbox{\usebox\ltx@zero}%
\endgroup
}
-
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@refxform}
+% \begin{macrocode}
\def\atfi@refxform#1{%
\raisebox{-\atfi@appearancedepth}{%
\atfi@literal{%
@@ -1753,9 +2301,13 @@ and the derived files
}%
\rule{0pt}{\atfi@appearanceheight}%
}
-
-% ---
-
+% \end{macrocode}
+% \end{macro}
+%
+% \paragraph{File attachment annotation}
+%
+% \begin{macro}{\atfi@insert@file@annot}
+% \begin{macrocode}
\def\atfi@insert@file@annot#1{%
\rule{0pt}{0pt}%
\ifatfi@appearance
@@ -1767,11 +2319,12 @@ and the derived files
>>%
}%
\else
- \let\atfi@appearance@dict\@empty
+ \let\atfi@appearance@dict\ltx@empty
\fi
- \@ifundefined{atfi@fsobj@#1}{%
+ \ltx@IfUndefined{atfi@fsobj@#1}{%
\stepcounter{atfi@obj}%
- \expandafter\xdef\csname atfi@fsobj@#1\endcsname{\theatfi@obj}%
+ \expandafter
+ \xdef\csname atfi@fsobj@#1\endcsname{\theatfi@obj}%
\begingroup
\hypersetup{unicode=false}%
\atfi@pdfstringdef\atfi@file{#1}%
@@ -1785,7 +2338,7 @@ and the derived files
<<%
/Type/Filespec%
/F(\atfi@file)%
- \ifx\atfi@ucfilespec\@empty
+ \ifx\atfi@ucfilespec\ltx@empty
\else
/UF(\atfi@ucfilespec)%
\fi
@@ -1816,9 +2369,11 @@ and the derived files
\strip@pt\dimexpr\atfi@scale\atfi@appearancedepth\relax
\space atfi_pdftodvipsy add %
currentpoint %
- exch \strip@pt\dimexpr\atfi@scale\atfi@appearancewidth\relax
+ exch %
+ \strip@pt\dimexpr\atfi@scale\atfi@appearancewidth\relax
\space atfi_pdftodvipsx add %
- exch \strip@pt\dimexpr\atfi@scale\atfi@appearanceheight\relax
+ exch %
+ \strip@pt\dimexpr\atfi@scale\atfi@appearanceheight\relax
\space atfi_pdftodvipsy sub %
]%
/ANN pdfmark%
@@ -1828,52 +2383,295 @@ and the derived files
\rule{\atfi@appearancewidth}{0pt}%
}
% \end{macrocode}
+% \end{macro}
+%
% \begin{macrocode}
%</dvips>
% \end{macrocode}
%
+% \subsubsection{dvipdfmx}
+%
+% \begin{macrocode}
+%<*dvipdfmx>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesFile{atfi-dvipdfmx.def}%
+ [2010/09/27 v2.6 attachfile2 driver for dvipdfmx/XeTeX (HO)]%
+% \end{macrocode}
+%
+% \paragraph{Macros for graphics data}
+%
+% \begin{macro}{\atfi@special}
+% \begin{macrocode}
+\def\atfi@special#1{%
+ \special{pdf:#1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@literal}
+% \begin{macrocode}
+\def\atfi@literal#1{%
+ \atfi@special{content #1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\def\atfi@GSAVE{q }
+\def\atfi@GRESTORE{Q }
+\def\atfi@SETLINEWIDTH{w }
+\def\atfi@LINETO{l }
+\def\atfi@MOVETO{m }
+\def\atfi@STROKE{S }
+\def\atfi@FILL{f }
+\def\atfi@FILLSTROKE#1#2{#1#2B }
+\def\atfi@SETRGBCOLORSTROKE{RG }
+\def\atfi@SETRGBCOLORFILL{rg }
+\def\atfi@SETGRAYSTROKE{G }
+\def\atfi@SETGRAYFILL{g }
+\def\atfi@SETCMYKCOLORSTROKE{K }
+\def\atfi@SETCMYKCOLORFILL{k }
+\def\atfi@RECTFILL{re f }
+\def\atfi@RECTSTROKEFILL#1#2#3{#1#2#3re B }
+\def\atfi@SETMITERLIMIT{M }
+\def\atfi@SETFLAT{i }
+\def\atfi@SETLINECAP{J }
+\def\atfi@CURVETO{c }
+\def\atfi@CURVETOV{v }
+\def\atfi@CURVETOY{y }
+\def\atfi@CLOSEPATH{h }
+\def\atfi@SETLINEJOIN{j }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newcounter{atfi@obj}
+\renewcommand*{\theatfi@obj}{%
+ @atfi_obj_\number\c@atfi@obj
+}
+% \end{macrocode}
+%
+% \paragraph{File embedding}
+%
+% \begin{macrocode}
+\define@key{AtFi@file}{Size}{%
+ \edef\atfi@params{\atfi@params/Size #1}%
+}
+% \end{macrocode}
+% \begin{macro}{\atfi@embedfile}
+% \begin{macrocode}
+\def\atfi@embedfile#1{%
+ \ltx@IfUndefined{atfi@fileobj@#1}{%
+ \stepcounter{atfi@obj}%
+ \begingroup
+ \let\atfi@params\ltx@empty
+ \expandafter\let\expandafter\atfi@temp
+ \csname atfi@file@#1\endcsname
+ \ifx\atfi@temp\ltx@empty
+ \let\atfi@temp\relax
+ \fi
+ \ifx\atfi@temp\relax
+ \atfi@pdftexdata{#1}%
+ \else
+ \edef\x{%
+ \noexpand\setkeys{AtFi@file}{\@nameuse{atfi@file@#1}}%
+ }%
+ \x
+ \fi
+ \ifx\atfi@params\ltx@empty
+ \else
+ \edef\atfi@params{/Params<<\atfi@params>>}%
+ \fi
+ \edef\atfi@FILE{#1}%
+ \filename@parse\atfi@FILE
+ \ifx\filename@area\ltx@empty
+ \edef\atfi@FILE{./\atfi@FILE}%
+ \fi
+ \EdefEscapeString\atfi@FILE{\atfi@FILE}%
+ \atfi@special{fstream %
+ \theatfi@obj
+ (\atfi@FILE)%
+ <<%
+ /Type/EmbeddedFile%
+ \atfi@mimetype
+ \atfi@params
+ >>%
+ }%
+ \atfi@special{close \theatfi@obj}%
+ \expandafter
+ \xdef\csname atfi@fileobj@#1\endcsname{\theatfi@obj}%
+ \endgroup
+ }{%
+ % file already embedded
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \paragraph{Annotation appearance}
+%
+% \begin{macro}{\atfi@xform}
+% input: \cs{atfi@appearancebox}, output: \cs{atfi@appearanceobj}
+% \begin{macrocode}
+\def\atfi@xform{%
+ \stepcounter{atfi@obj}%
+ \smash{%
+ \rlap{%
+ \atfi@special{bxobj \theatfi@obj\space
+ width \the\wd\atfi@appearancebox\space
+ height \the\ht\atfi@appearancebox\space
+ depth \the\dp\atfi@appearancebox
+ }%
+ \usebox\atfi@appearancebox
+ \atfi@special{exobj}%
+ }%
+ }%
+ \edef\atfi@appearanceobj{\theatfi@obj}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\atfi@xform@icon}
+% \begin{macrocode}
+\let\atfi@xform@icon\atfi@xform
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\atfi@refxform}
+% \begin{macrocode}
+\def\atfi@refxform#1{%
+ \leavevmode
+ \atfi@special{uxobj #1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \paragraph{File attachment annotation}
+%
+% \begin{macro}{\atfi@insert@file@annot}
+% \begin{macrocode}
+\def\atfi@insert@file@annot#1{%
+ \rule{0pt}{0pt}%
+ \ifatfi@appearance
+ \def\atfi@appearance@dict{%
+ /AP<<%
+ /N \atfi@appearanceobj
+ /R \atfi@appearanceobj
+ /D \atfi@appearanceobj
+ >>%
+ }%
+ \else
+ \let\atfi@appearance@dict\ltx@empty
+ \fi
+ \ltx@IfUndefined{atfi@fsobj@#1}{%
+ \begingroup
+ \ifxetex
+ \let\atfi@temp\Hy@Warning
+ \let\Hy@Warning\ltx@gobble
+ \fi
+ \hypersetup{unicode=false}%
+ \ifxetex
+ \let\Hy@Warning\atfi@temp
+ \fi
+ \atfi@pdfstringdef\atfi@file{#1}%
+ \stepcounter{atfi@obj}%
+ \atfi@special{obj \theatfi@obj <<%
+ /Type/Filespec%
+ /F(\atfi@file)%
+ \ifx\atfi@ucfilespec\ltx@empty
+ \else
+ /UF(\atfi@ucfilespec)%
+ \fi
+ /EF<<%
+ /F \@nameuse{atfi@fileobj@#1}%
+ >>%
+ >>%
+ }%
+ \expandafter\xdef\csname atfi@fsobj@#1\endcsname{%
+ \theatfi@obj
+ }%
+ \endgroup
+ }{%
+ }%
+ \begingroup
+ \dimen@=\atfi@scale\atfi@appearancewidth
+ \edef\atfi@rule{width \the\dimen@}%
+ \dimen@=\atfi@scale\atfi@appearanceheight
+ \edef\atfi@rule{\atfi@rule\space height \the\dimen@}%
+ \dimen@=\atfi@scale\atfi@appearancedepth
+ \edef\atfi@rule{\atfi@rule\space depth \the\dimen@}%
+ \atfi@special{ann \atfi@rule
+ <<%
+ /Subtype/FileAttachment%
+ \atfi@icon
+ \atfi@color@annot
+ \atfi@author
+ \atfi@date
+ \atfi@annotname
+ \atfi@description
+ \atfi@subject
+ \atfi@appearance@dict
+ /F \theatfi@flags
+ /FS \@nameuse{atfi@fsobj@#1}%
+ >>%
+ }%
+ \endgroup
+ \rule{0pt}{\atfi@appearanceheight}%
+ \rule[-\atfi@appearancedepth]{0pt}{\atfi@appearancedepth}%
+ \rule{\atfi@appearancewidth}{0pt}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macrocode}
+%</dvipdfmx>
+% \end{macrocode}
+%
% \subsection{Perl script \xfile{pdfatfi.pl}}
%
% \begin{macrocode}
%<*pdfatfi>
% \end{macrocode}
+% \begingroup\small
+% \SpecialEscapechar\|
% \begin{macrocode}
-eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q'
- if 0;
+#!/usr/bin/env perl
use strict;
$^W=1; # turn warning on
#
# pdfatfi.pl
#
-# Copyright (C) 2005, 2006 Heiko Oberdiek.
+# Copyright (C) 2005-2010 Heiko Oberdiek.
#
# This work may be distributed and/or modified under the
-# conditions of the LaTeX Project Public License, either version 1.3
-# of this license or (at your option) any later version.
-# The latest version of this license is in
-# http://www.latex-project.org/lppl.txt
-# and version 1.3 or later is part of all distributions of LaTeX
-# version 2005/12/01 or later.
+# conditions of the LaTeX Project Public License, either
+# version 1.3c of this license or (at your option) any later
+# version. This version of this license is in
+# http://www.latex-project.org/lppl/lppl-1-3c.txt
+# and the latest version of this license is in
+# http://www.latex-project.org/lppl.txt
+# and version 1.3 or later is part of all distributions of
+# LaTeX version 2005/12/01 or later.
#
# This work has the LPPL maintenance status "maintained".
#
# This Current Maintainer of this work is Heiko Oberdiek.
#
-# See file "attachfile2.pdf" for a list of files that belong to this project.
+# See file "attachfile2.pdf" for a list of files that belong to
+# this project.
#
# This file "pdfatfi.pl" may be renamed to "pdfatfi"
# for installation purposes.
#
my $file = "pdfatfi.pl";
my $program = uc($&) if $file =~ /^\w+/;
-my $version = "2.5";
-my $date = "2009/09/25";
+my $version = "2.6";
+my $date = "2010/09/27";
my $author = "Heiko Oberdiek";
-my $copyright = "Copyright (c) 2005, 2006 by $author.";
+my $copyright = "Copyright (c) 2005-2010 by $author.";
#
# History:
# 2005/05/21 v1.0: First release.
# 2006/08/16 v2.2: Included in DTX file of attachfile2.dtx.
+# 2010/09/27 v2.6: Keys ModDateTZ and CreationDateTZ added.
#
use POSIX qw(strftime); # %z is used (GNU)
@@ -1898,11 +2696,11 @@ $::opt_verbose = 0;
my $usage = <<"END_OF_USAGE";
${title}Syntax: \L$program\E [options] <file[.atfi]>
Function: Help program for LaTeX package "attachfile2".
-Options: (defaults:)
+Options: (defaults:)
--help print usage
- --(no)quiet suppress messages ($bool[$::opt_quiet])
- --(no)verbose verbose printing ($bool[$::opt_verbose])
- --(no)debug debug informations ($bool[$::opt_debug])
+ --(no)quiet suppress messages ($bool[$::opt_quiet])
+ --(no)verbose verbose printing ($bool[$::opt_verbose])
+ --(no)debug debug informations ($bool[$::opt_debug])
END_OF_USAGE
### process options
@@ -1941,7 +2739,15 @@ END_DEB
my $tmpfile = $atfifile . ".tmp";
my $timezone = strftime "%z", localtime;
-$timezone =~ s/^([+\-]\d\d)(\d\d)$/$1'$2'/;
+
+sub gettz ($) {
+ my $time = shift;
+ my $tz = strftime "%z", localtime($time);
+ return '' unless $tz;
+ return 'Z' if $tz eq '+0000';
+ $tz =~ s/^([+\-]\d\d)(\d\d)$/$1'$2'/;
+ return $tz;
+}
open(IN, $atfifile) or die "$Error Cannot open `$atfifile'!\n";
open(OUT, ">$tmpfile") or die "$Error Cannot write `$tmpfile'!\n";
@@ -1965,20 +2771,26 @@ while(<IN>) {
my $mtime = @s[9];
my $ctime = @s[10]; # inode change time
- my ($sec, $min, $hour, $mday, $mon, $year) = localtime($mtime);
+ my ($sec, $min, $hour, $mday, $mon, $year) =
+ localtime($mtime);
my $moddate = sprintf("%04d%02d%02d%02d%02d%02d",
$year + 1900, $mon + 1, $mday,
$hour, $min, $sec);
+ my $moddatetz = 'D:' . $moddate . gettz($mtime);
# Manual page "perlport" says that "ctime" is creation
# time instead of inode change time for "Win32" and
# "Mac OS", but it is unsupported for "Mac OS X".
my $creationdate = "";
+ my $creationdatetz = "";
if ($^O eq 'MSWin32') { # cygwin?
- ($sec, $min, $hour, $mday, $mon, $year) = localtime($ctime);
+ ($sec, $min, $hour, $mday, $mon, $year) =
+ localtime($ctime);
$creationdate = sprintf("%04d%02d%02d%02d%02d%02d",
$year + 1900, $mon + 1, $mday,
$hour, $min, $sec);
+ $creationdatetz =
+ 'D:' . $creationdate . gettz($ctime);
}
# md5 checksum
@@ -1995,15 +2807,20 @@ while(<IN>) {
}
$_ = "\\attachfile\@file["
- . "ModDate=$moddate,Size=$size"
- . (($checksum) ? ",CheckSum=$checksum" : "")
- . (($creationdate) ? ",CreationDate=$creationdate" : "")
+ . "ModDateTZ=$moddatetz"
+ . ",Size=$size"
+ . ($checksum ? ",CheckSum=$checksum" : "")
+ . ($creationdatetz ?
+ ",CreationDateTZ=$creationdatetz" :
+ ($creationdate ?
+ ",CreationDate=$creationdate" : ""))
. "]{$hexfile}\n";
if ($::opt_verbose) {
print "* file entry = $file\n";
print " size = $size\n";
print " moddate = $moddate\n";
- print " creationdate = $creationdate\n" if $creationdate;
+ print " creationdate = $creationdate\n"
+ if $creationdate;
print " checksum = $checksum\n" if $checksum;
}
}
@@ -2023,6 +2840,7 @@ print "*** ready. ***\n" unless $::opt_quiet;
__END__
% \end{macrocode}
+% \endgroup
% \begin{macrocode}
%</pdfatfi>
% \end{macrocode}
@@ -2088,8 +2906,9 @@ __END__
% \def\t{^^A
% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
% attachfile2.sty & tex/latex/oberdiek/attachfile2.sty\\
-% atfidvips.def & tex/latex/oberdiek/atfidvips.def\\
-% atfipdftex.def & tex/latex/oberdiek/atfipdftex.def\\
+% atfi-dvips.def & tex/latex/oberdiek/atfi-dvips.def\\
+% atfi-pdftex.def & tex/latex/oberdiek/atfi-pdftex.def\\
+% atfi-dvipdfmx.def & tex/latex/oberdiek/atfi-dvipdfmx.def\\
% pdfatfi.pl & scripts/oberdiek/pdfatfi.pl\\
% attachfile2.pdf & doc/latex/oberdiek/attachfile2.pdf\\
% attachfile2.dtx & source/latex/oberdiek/attachfile2.dtx\\
@@ -2305,6 +3124,30 @@ __END__
% Fix: \xpackage{hyperref}'s option \xoption{unicode} is disabled
% for file names except for \xoption{ucfilespec}.
% \end{Version}
+% \begin{Version}{2010/09/27 v2.6}
+% \item
+% Support for dvipdfmx added, new option \xoption{dvipdfmx}
+% and alias option \xoption{xetex}.
+% (Thanks Will Robertson for pointing to |\special{pdf:fstream ...}|).
+% \item
+% New option \xoption{driverfallback}.
+% \item
+% All options except driver options are local options,
+% that means they are ignored as global options.
+% \item
+% Some options are disabled after they are used
+% (driver options, \xoption{draft}, \xoption{final}, \xoption{nofiles}).
+% \item
+% Driver files renamed from \texttt{atfi<driver>.def} to
+% \texttt{atfi-<driver>.def}.
+% \item
+% Bug fix: \cs{textattachfile} now adds an entry into
+% the \xext{atfi} file.
+% \item
+% Program pdfatfi.pl sets modification and creation time with
+% time zone, because the time zone offset might differ with
+% the file date.
+% \end{Version}
% \end{History}
%
% \PrintIndex