summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/mkstmpdad/mkstmp_pro.dtx
blob: bcffd9cbffabd8717e6ed145a250711d278bfd44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
% \iffalse
% makeindex -s gglo.ist -o mkstmp_pro.gls mkstmp_pro.glo
% makeindex -s gind.ist -o mkstmp_pro.ind mkstmp_pro.idx
%<*copyright>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% mkstmp_pro package                                   %%
%% Copyright (C) 2012-2016  D. P. Story                 %%
%%   dpstory@uakron.edu                                 %%
%%                                                      %%
%% This program can redistributed and/or modified under %%
%% the terms of the LaTeX Project Public License        %%
%% Distributed from CTAN archives in directory          %%
%% macros/latex/base/lppl.txt; either version 1 of the  %%
%% License, or (at your option) any later version.      %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%</copyright>
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{mkstmp_pro}
%<package> [2016/08/21 v1.1 Make Stamps for stamp annotations (dps)]
%<*driver>
\documentclass{ltxdoc}
\usepackage[colorlinks,hyperindex=false]{hyperref}[2012/10/12] % to support calculate for pdfyrc
\pdfstringdefDisableCommands{\let\\\textbackslash}
\OnlyDescription
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\def\ltag{<}\def\rtag{>}
\InputIfFileExists{aebdocfmt.def}{\PackageInfo{mkstmp_pro}{Inputting aebdocfmt.def}}
    {\def\IndexOpt{\DescribeMacro}\def\IndexKey{\DescribeMacro} \let\setupFullwidth\relax
     \PackageInfo{mkstmp_pro}{aebdocfmt.def cannot be found}}
\begin{document}
  \GetFileInfo{mkstmp_pro.sty}
  \title{\textsf{mkstmp\_pro}: Create stamps for \textsf{AA/AAR}}
  \author{D. P. Story\\
    Email: \texttt{dpstory@uakron.edu}}
  \date{processed \today}
  \maketitle
  \tableofcontents
  \let\Email\texttt
  \DocInput{mkstmp_pro.dtx}
\IfFileExists{\jobname.ind}{\newpage\setupFullwidth\PrintIndex}{\paragraph*{Index} The index goes here.\\Execute
    \texttt{makeindex -s gind.ist -o mkstmp\_pro.ind mkstmp\_pro.idx} on the command line and recompile
    \texttt{mkstmp\_pro.dtx}.}
\IfFileExists{\jobname.gls}{\PrintChanges}{\paragraph*{Change History} The list of changes goes here.\\Execute
    \texttt{makeindex -s gglo.ist -o mkstmp\_pro.gls mkstmp\_pro.glo} on the command line and recompile
    \texttt{mkstmp\_pro.dtx}.}
\end{document}
%</driver>
% \fi
%
% \MakeShortVerb{|}
% \InputIfFileExists{aebdonotindex.def}{\PackageInfo{mkstmp_pro}{Inputting aebdonotindex.def}}
%    {\PackageInfo{mkstmp_pro}{aebdonotindex.def cannot be found}}
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
% \paragraph*{Description.}
% \textsf{mkstmp\_pro} is a package for making a (rubber) stamp file.
% A person using this package requires \textsf{aeb\_pro} and \textsf{Adobe Acrobat} (\texttt{AA}).
% After you create a stamp file, move it to the user stamp folder of your \textsf{Acrobat}
% distribution and the stamps will be available for use.
%
% \paragraph*{Documentation and Code.}\strut\par\medskip\noindent
% We require the \textsf{aeb\_pro} and \textsf{xkeyval} packages.
%    \begin{macrocode}
\RequirePackage{aeb_pro}[2012/11/09]
\RequirePackage{xkeyval}
%    \end{macrocode}
% A command taken from \textsf{eforms} that can be used to define
% \cs{setStampPath}.
%    \begin{macrocode}
\providecommand{\definePath}[1]{\def\ef@ctrlName{#1}%
    \hyper@normalise\ef@definePath}
\def\ef@definePath#1{\expandafter\xdef\ef@ctrlName{#1}}
%    \end{macrocode}
% \DescribeMacro{\setStampPath} is used to define the path to the icon
% file. It is a declaration that uses \cs{definePath} to define the
% macro \cs{stampPath}. If used, then the \texttt{path} key is not used (defined below).
%    \begin{macrocode}
\newcommand{\setStampPath}[1]{\definePath{\msp@stampPath}{#1}}
%    \end{macrocode}
% Key value pairs for the \texttt{makeStamp} family.\par\medskip\noindent
% \DescribeMacro{name} is the name you are giving the stamp.
%    \begin{macrocode}
\define@key{makeStamp}{name}[]{\def\makeStamp@name{\##1}}
\let\msp@stampPath\@empty
%    \end{macrocode}
% \DescribeMacro{path} is the path to the PDF file containing the image
% to be used for a stamp. The default is \cs{msp@stampPath}, defined separately
% using \cs{setStampPath}.
%    \begin{macrocode}
\define@key{makeStamp}{path}[\msp@stampPath]{\edef\makeStamp@path{#1}}
%    \end{macrocode}
% \DescribeMacro{page} is the page in the PDF file that corresponds to the
% image you want to use as a stamp.
%    \begin{macrocode}
\define@key{makeStamp}{page}[0]{\def\aeb@stamp@page{#1}}
%    \end{macrocode}
% \DescribeMacro{\makeStamps} is the only command of this package. Its only
% argument is a list of tokens.
%\begin{verbatim}
%   \setStampPath{C:/Users/Public/Documents/%
%        My TeX Files/tex/latex/aeb/aebpro/aeb_dad/images/juergen.pdf}
%   \makeStamps{%
%        {name=Touches Hat,page=0}
%        {name=Doffs Hat,page=1}
%        {name=Movie Star,page=2}
%        {name=Running Man,page=3}
%   }
%   \begin{docassembly}
%   \insertPreDocAssembly
%   \end{docassembly}
%   \begin{document}
%   ...
%\end{verbatim}
% There are three key-value pairs. name, path, and page. The path key is not really
% needed if the command \cs{setStampPath} is used.
%    \begin{macrocode}
\newcommand{\makeStamps}[1]{%
    \edef\@tforExp{\noexpand\@tfor\noexpand\msp@Args:=#1}%
    \@tforExp\do{\expandafter\ms@makeStamp
        \expandafter{\msp@Args}%
    }%
}
%    \end{macrocode}
% \cs{makeStamp} is a loop that calls \cs{ms@makeStamp}. A typical call
% is
%\begin{verbatim}
%   \ms@makeStamp{name=Touches Hat,page=0}
%\end{verbatim}
%    \begin{macrocode}
\newcommand{\ms@makeStamp}[1]{%
    \setkeys{makeStamp}{name,path,page,#1}%
    \ifx\make@Stamps@name\@empty
        \PackageError{mkstmp_pro}{The `name' key is required}
            {Please give the path of the stamp image.}\fi
    \ifx\makeStamp@path\@empty
        \PackageError{mkstmp_pro}{The `path' key is required}
            {Please give the path of the stamp image, or \MessageBreak
            use \string\setStampPath.}\fi
%    \end{macrocode}
% We work things so that the pages are added in the same order that they
% are listed in the arguments of \cs{makeStamp}.
%
% We create a command \cs{predocassemJS} that is designed for use in the
% \texttt{docassembly} environment of \textsf{aeb\_pro}.
%    \begin{macrocode}
    \xdef\predocassemJS{%
        var retn=\insertPages({nPage:0, cPath:"\makeStamp@path",%
        nStart:\aeb@stamp@page});^^J%
        if ( retn==-1 ) console.println("The file
        \string\"\makeStamp@path\string\" could not be opened.");^^J%
        if ( retn==-2 ) console.println("Selected page
        (page=\aeb@stamp@page) for \string\"\makeStamp@path\string\"
        is invalid.");^^J%
        \createTemplate({cName:"\makeStamp@name",nPage:1});^^J%
        \predocassemJS%
    }%
}
%    \end{macrocode}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%\Finale