summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/icon-appr/icon-appr.dtx
blob: 14a77bbbf2f8b545b4c7c938f8c87e455c2455a2 (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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
% \iffalse
%<*copyright>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% icon-appr.sty package,                                %%
%% Copyright (C) 2018--2020                              %%
%% dpstory@acrotex.net                                   %%
%%                                                       %%
%% 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.2 of the %%
%% License, or (at your option) any later version.       %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%</copyright>
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{icon-appr}
%<package> [2020/06/13 v1.2.1 Provides icon appearances for button fields (dps)]
%<*driver>
\documentclass{ltxdoc}
\usepackage[colorlinks,hyperindex=false]{hyperref}
\OnlyDescription  % comment out for implementation details
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\InputIfFileExists{aebdocfmt.def}{\PackageInfo{icon-appr}{Inputting aebdocfmt.def}}
    {\def\IndexOpt{\DescribeMacro}\def\IndexKey{\DescribeMacro}\let\setupFullwidth\relax
     \PackageInfo{icon-appr}{aebdocfmt.def cannot be found}}
\begin{document}
\def\CMD#1{\textbackslash#1}
\let\pkg\textsf
\let\opt\texttt
\let\env\texttt
\let\app\textsf
\def\psf#1{\textsf{\textbf{#1}}}
\def\darg#1{\texttt{\char123\relax#1\char125\relax}}
\def\ameta#1{\ensuremath{\langle\textit{\texttt{#1}}\rangle}}
\def\meta#1{\textsl{\texttt{#1}}}
\GetFileInfo{icon-appr.sty}
\title{The \textsf{icon-appr} Package}
\author{D. P. Story\\
  Email: \texttt{dpstory@acrotex.net}}
\date{processed \today}
\maketitle
\tableofcontents
\let\Email\texttt
\DocInput{icon-appr.dtx}
\IfFileExists{\jobname.ind}{\newpage\setupFullwidth\par\PrintIndex}{\paragraph*{Index} The index goes here. Execute
    \begin{quote}
    \texttt{makeindex -s gind.ist -o icon-appr.ind icon-appr.idx}
    \end{quote}
    on the command line and recompile \texttt{icon-appr.dtx}.}
\IfFileExists{\jobname.gls}{\PrintChanges}{\paragraph*{Change History} The list of changes goes here. Execute
    \begin{quote}
    \texttt{makeindex -s gglo.ist -o icon-appr.gls icon-appr.glo}
    \end{quote}
    on the command line and recompile \texttt{icon-appr.dtx}.}
\end{document}
%</driver>
% \fi
% \MakeShortVerb{|}
% \InputIfFileExists{aebdonotindex.def}{\PackageInfo{icon-appr}{Inputting aebdonotindex.def}}
%    {\PackageInfo{icon-appr}{cannot find aebdonotindex.def}}
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%    \section{Required packages}
%    \begin{macrocode}
\RequirePackage{xkeyval}
\RequirePackage{ifpdf}[2006/02/20]
\RequirePackage{ifxetex}[2006/08/21]
\RequirePackage{ifluatex}
\RequirePackage{eforms}[2018/11/10]
\RequirePackage{graphicx}
\@ifundefined{ifpdfmarkup}{\newif\ifpdfmarkup}{}\pdfmarkupfalse
\ifpdf\else\ifxetex\else\pdfmarkuptrue\fi\fi
\ifpdfmarkup\else
\def\ReqPkg{\RequirePackage{datatool}}\expandafter
\ReqPkg\fi
%    \end{macrocode}
%    \section{Introduction}
%    The \cs{special}s and primitives of \app{pdflatex}, \app{lualatex}, and \app{xelatex} are used to provide support for inserting
%    icon appearances into a button form field. We require \pkg{eforms} (2018/11/10) to create the form fields because
%    the form support by \pkg{hyperref} does not provide the entries in a button field to create icon appearances. This
%    package also supports icon appearances for \app{dvips} and \app{dvipsone} when the \pkg{aeb\_pro} package is used
%    and \app{Acrobat Distiller} or \app{ps2pdf} is used as the PDF creator, but in both cases, \app{Adobe Acrobat} must
%    be the primary PDF viewer.\footnote{This means the newly created PDF must be opened with \app{Acrobat} and saved before
%    the file is ready for general use.}
%    \section{Utility commands}
%    \subsection{Macros based on the \textsf{datatool} package}
%    This version (2020/06/05 v1.2) of \pkg{icon-appr} attempts create the \textsf{\textbf{AP}}
%    in the \textsf{\textbf{Names}} dictionary of the PDF catalog. A problem arose when I read from the PDF specification
%    that the entries must be listed \emph{alphabetically}. After a quick search of the internet
%    for {\LaTeX} packages that can alphabetize a list, came across a
%    \href{https://tex.stackexchange.com/questions/121489/alphabetically-display-the-items-in-itemize}{tex.stackexchange.com} page,
%    which solved the problem for me. In the lines below, the code from that page is modified to do the task I need it to do.
%    \begin{macrocode}
\newtoks\IA@IconsAlpha \IA@IconsAlpha={}
\let\IA@Icons\@empty
\let\IA@Icons@pdfmark\@empty
\let\IA@Icons@pdfmark@Names\@empty
\newcommand{\sortitem}[2][\relax]{%
  \DTLnewrow{list}% Create a new entry
  \ifx#1\relax
    \DTLnewdbentry{list}{sortlabel}{#2}%
  \else
    \DTLnewdbentry{list}{sortlabel}{#1}%
  \fi%
  \DTLnewdbentry{list}{description}{#2}%
}
\newenvironment{sortedlist}{%
  \DTLifdbexists{list}{\DTLcleardb{list}}{\DTLnewdb{list}}%
}{%
  \DTLsort{sortlabel}{list}% Sort list
  \DTLforeach*{list}{\theDesc=description}{\theDesc}%
}
\def\IA@sortitem#1{\sortitem[#1]{\IA@sortitemArgii{#1}}}
\def\IA@sortitemArgii#1{\edef\z{\global
  \IA@IconsAlpha={\the\IA@IconsAlpha (#1) \eq@relRef{\csOf{#1}}}}\z}
%    \end{macrocode}
%   \subsection{Other preliminaries}
%    \begin{macrocode}
\def\x@namedef#1{\expandafter\xdef\csname #1\endcsname}
\def\heightOf#1{\@nameuse{#1heightOf}}
\def\widthOf#1{\@nameuse{#1widthOf}}
\newif\if@bEmbed \@bEmbedfalse
\newif\if@EmbedIconUsed \@EmbedIconUsedfalse
\newif\if@EmbedEPSUsed \@EmbedEPSUsedfalse
%    \end{macrocode}
%    \leavevmode\DescribeMacro\csOf\hskip-\marginparsep\darg{\ameta{name}}
%      Use \cs{csOf} to expand a control name.
%    \begin{macrocode}
\@ifundefined{csOf}{\let\csOf\@nameuse}{}
\let\IA@CreateImage@xsp\@empty
\let\IA@EndEmbedding@aebpro\relax
%    \end{macrocode}
%    \section{The main commands}
%    \begin{macrocode}
\define@key{IAKVfamily}{name}[]{\def\IAKVfamily@name{#1}}
\define@key{IAKVfamily}{hyopts}[]{\def\IAKVfamily@hyopts{#1}}
\define@key{IAKVfamily}{cipresp}[]{\def\IAKVfamily@presp{#1}}
\define@key{IAKVfamily}{cipostsp}[]{\def\IAKVfamily@postsp{#1}}
\let\IAKVfamily@name\@empty
\let\IAKVfamily@hyopts\@empty
\let\IAKVfamily@presp\@empty
\let\IAKVfamily@postsp\@empty
%    \end{macrocode}
%\subsection{The \texttt{embedding} environment}
%    \begin{environment}{embedding}
%    The \env{embedding} environment encloses are embedding commands (\cs{embedIcon}
%    and \cs{embedEPS}).
%    \begin{macrocode}
\newenvironment{embedding}{\def\IA@mark{[\space}\global\@bEmbedtrue
  \@ifpackageloaded{graphicxsp}{\let\IA@embedEPS@save\embedEPS
    \let\embedEPS\IA@embedEPS}{\let\embedEPS\IA@embedEPS@null}%
}{\global\@bEmbedfalse
%    \end{macrocode}
%     (2020/06/05) In this, the \cs{end\darg{embedding}} part of the environment,
%     one or more \cs{embedIcon} commands have been inserted in the
%     \cs{begin\darg{embedding}} part of the environment. A list \cs{IA@Icons} is
%     built, beginning with \cs{begin\darg{sortedlist}}. Here, we close
%     that environment. Then, if a \app{dvips\texttt{->}distiller} workflow \emph{is not being
%     used}, we close the \env{sortedlist} environment, then expand \cs{IA@Icons},
%     which should alphabetize the icon names, and leave results in the token
%     register \cs{IA@IconsAlpha}, which we insert into the \textsf{\textbf{AP}} dictionary
%     into the \textsf{\textbf{Names}} dictionary of the PDF catalog. The results looks
%     like this (taken from one of my test files):
%\begin{verbatim}
%   <</AP<</Names[(girl)27 0 R(mani)36 0 R(scot)41 0 R]>> >>
%\end{verbatim}
%Note the entries of the \textsf{\textbf{Names}} dictionary of the
%\textsf{\textbf{AP}} dictionary are listed in alphabetical order along with
%their respective indirect reference.
%    \begin{macrocode}
  \g@addto@macro\IA@Icons{\end{sortedlist}}
%    \end{macrocode}
%     We expand \cs{IA@Icons} only if not a pdfmark workflow, this is were the list of icon names
%     is sorted.
%    \begin{macrocode}
  \ifpdfmarkup\else\expandafter\IA@Icons\fi
%    \end{macrocode}
%     Write the \textbf{\sffamily AP} dictionary to the \textbf{\sffamily Names}
%     dictionary for each driver.
%    \changes{v1.1}{2020/06/04}{Entry in the icons array}
%    \begin{macrocode}
  \ifluatex
    \ifx\IA@Icons\@empty\else
      \pdfextension names{/AP <</Names[\the\IA@IconsAlpha]>>}\fi
  \else\ifpdf
      \ifx\IA@Icons\@empty\else
        \immediate\pdfnames{/AP <</Names[\the\IA@IconsAlpha]>>}\fi
  \else\ifxetex
      \ifx\IA@Icons\@empty\else
        \immediate\@pdfm@mark{obj @iconnames %
          << /Names [\the\IA@IconsAlpha] >> }%
        \@pdfm@mark{put @names %
          << /AP @iconnames >> }\fi
  \fi\fi\fi
  \gdef\IA@EndEmbedding{\IA@EndEmbedding@aebpro
  \IA@CreateImage@xsp}\aftergroup\IA@EndEmbedding
}
%    \end{macrocode}
%   The commands \cs{embedIcon} and \cs{embedEPS} are placed inside the \env{embedding} environment.
%    \end{environment}
%
%    \subsection{The \texorpdfstring{\cs{embedIcon}}{\textbackslash{embedIcon}} command}
%
%    \begin{macro}{\embedIcon}
%    \hskip-\marginparsep\texttt{[\ameta{KVPairs}]\darg{\ameta{path}}}
%    This is the main embedding command of the package. An example of use
%    is given below, as taken from \texttt{icons-appr-exmpl1.tex}.
%\begin{verbatim}
%\begin{embedding}
%   \embedIcon[name=mani]{graphics/man1.pdf}
%   \embedIcon[name=girl]{graphics/girl.pdf}
%   \embedIcon[name=scot]{graphics/scot.pdf}
%\end{embedding}
%\end{verbatim}
%The \texttt{name} key is required for non-pdfmark drivers, its value must consist only of letters (or possibly non-active characters).
%The name value, say `mani', is made into a control sequence, which may be referred to by
%\cs{mani} or \cs{csOf\darg{mani}}.
%
%The syntax for \app{dvips}/\app{dvipsone} is more complicated, we refer the user
%to the sample file \texttt{icons-appr-pb.tex}.
%
%Initially, we test whether \cs{embedIcon} is enclosed in the \cs{bEmbeddeind}/\allowbreak
%\cs{eEmbedding} command pair. If yes, we fork off to any of five versions of \cs{embedIcon},
%internally named \cs{IA@embedIcon}:
% (1) one for \app{lualatex}; (2) one for \app{pdftex}; (3) one for \app{xelatex};
% (4) one for \app{dvips} with \pkg{aeb\_pro}; and (5)
% one for the otherwise case, it does nothing but does avoids stopping the tex engine.
%    \begin{macrocode}
\newcommand{\embedIcon}{\global\@EmbedIconUsedtrue
  \if@bEmbed\def\IA@next{\IA@embedIcon}\else
    \PackageWarning{icon-appr}{\string\embedIcon\space commands must be
    enclosed\MessageBreak in the embedding environment}%
    \def\IA@next{\IA@embedIcon@null}\fi
  \IA@next}
\def\IA@handle@name@empty#1{{\count0=\aeb@image@cnt
    \advance\count0by1\relax\xdef
    \aeb@image@cnt{\the\count0 }}%
    \edef\IAKVfamily@name{aebImage\aeb@image@cnt}%
    \PackageWarning{icon-appr}{%
    The `name' key is not specified,\MessageBreak
    will assign a name of `\IAKVfamily@name'\MessageBreak
    for the icon #1}}
%    \end{macrocode}
%    \textbf{Requirements of package not met.} This version makes a necessary
%    definition to avoid stopping the tex engine.
%    \begin{macrocode}
\newcommand{\IA@embedIcon@null}[2][]{%
  \begingroup
  \setkeys*{IAKVfamily}{#1}%
  \ifx\IAKVfamily@name\@empty\IA@handle@name@empty\fi
  \x@namedef{\IAKVfamily@name widthOf}{0pt}%
  \x@namedef{\IAKVfamily@name heightOf}{0pt}%
  \x@namedef{\IAKVfamily@name}{null}%
  \endgroup}
\let\IA@embedEPS@null\IA@embedIcon@null
\@ifundefined{aeb@image@cnt}{\def\aeb@image@cnt{0}}{}
\ifluatex
%    \end{macrocode}
%    \textbf{The \app{lualatex} driver.} The two \app{lualatex} commands \cs{saveboxresource} and
%    \cs{lastsavedboxresourceindex} are used.
%    \begin{macrocode}
\protected\def\pdfnames{\pdfextension names }
\newcommand{\IA@embedIcon}[2][]{\begingroup
  \setkeys*{IAKVfamily}{#1}%
  \ifx\IAKVfamily@name\@empty\IA@handle@name@empty{#2}\fi
  \toks@={\setbox\@tempboxa\hbox\bgroup\includegraphics}%
  \edef\x{\the\toks@[\IAKVfamily@hyopts]{#2}\egroup}\x
  \x@namedef{\IAKVfamily@name widthOf}{\the\wd\@tempboxa}%
  \x@namedef{\IAKVfamily@name heightOf}{\the\ht\@tempboxa}%
  \immediate\saveboxresource\@tempboxa
  \x@namedef{\IAKVfamily@name}
    {\the\lastsavedboxresourceindex}%
%    \end{macrocode}
%     (2020/06/05) Entry in the icons array
%    \begin{macrocode}
  \ifx\IA@Icons\@empty
    \g@addto@macro\IA@Icons{\begin{sortedlist}}\fi
  \protected@edef\x{\noexpand\g@addto@macro\noexpand
    \IA@Icons{\protect\IA@sortitem{\IAKVfamily@name}}}\x
\endgroup}
\else\ifpdf
%    \end{macrocode}
%    \textbf{The \app{pdflatex} driver.} The \app{pdflatex} commands \cs{pdfxform} and
%    \cs{pdflastxform} are used.
%    \begin{macrocode}
\newcommand{\IA@embedIcon}[2][]{\begingroup
  \setkeys*{IAKVfamily}{#1}%
  \ifx\IAKVfamily@name\@empty\IA@handle@name@empty{#2}\fi
  \toks@={\setbox\@tempboxa\hbox\bgroup\includegraphics}%
  \edef\x{\the\toks@[\IAKVfamily@hyopts]{#2}\egroup}\x
  \x@namedef{\IAKVfamily@name widthOf}{\the\wd\@tempboxa}%
  \x@namedef{\IAKVfamily@name heightOf}{\the\ht\@tempboxa}%
  \immediate\pdfxform\@tempboxa
  \x@namedef{\IAKVfamily@name}{\the\pdflastxform}%
%    \end{macrocode}
%     (2020/06/05) Entry in the icons array
%    \begin{macrocode}
  \ifx\IA@Icons\@empty
    \g@addto@macro\IA@Icons{\begin{sortedlist}}\fi
  \protected@edef\x{\noexpand\g@addto@macro\noexpand
    \IA@Icons{\protect\IA@sortitem{\IAKVfamily@name}}}\x
\endgroup}
\else\ifxetex
%    \end{macrocode}
%    \textbf{The \app{xelatex} driver.} The \app{xelatex} \cs{special}s \texttt{bxobj},
%    \texttt{image}, and \texttt{exobj} are used. The \texttt{image} syntax does not
%    support the concept of page for a PDF file, consequently, it always reads
%    the first page.
%    \begin{macrocode}
\newcommand{\IA@embedIcon}[2][]{\begingroup
  \setkeys*{IAKVfamily}{#1}%
  \ifx\IAKVfamily@name\@empty\IA@handle@name@empty{#2}\fi
  \toks@={\setbox\@tempboxa\hbox\bgroup\includegraphics}%
  \edef\x{\the\toks@[\IAKVfamily@hyopts]{#2}\egroup}\x
  \x@namedef{\IAKVfamily@name widthOf}{\the\wd\@tempboxa}%
  \x@namedef{\IAKVfamily@name heightOf}{\the\ht\@tempboxa}%
  \x@namedef{\IAKVfamily@name}{@\IAKVfamily@name}%
  \@pdfm@mark{bxobj @\IAKVfamily@name\space
    width \the\wd\@tempboxa \space
    height \the\ht\@tempboxa \space}%
  \@pdfm@mark{image width \the\wd\@tempboxa \space
    height \the\ht\@tempboxa \space (#2)}%
  \@pdfm@mark{exobj}%
%    \end{macrocode}
%    (2020/06/05) Entry in the icons array
%    \begin{macrocode}
  \ifx\IA@Icons\@empty
    \g@addto@macro\IA@Icons{\begin{sortedlist}}\fi
  \protected@edef\x{\noexpand\g@addto@macro\noexpand
    \IA@Icons{\protect\IA@sortitem{\IAKVfamily@name}}}\x
\endgroup}
\else
%    \end{macrocode}
%    If not any of the previously discussed drivers, it must a \textsf{\textbf{pdfmark}}-type driver.
%    \begin{macrocode}
\@ifpackageloaded{aeb_pro}{%
%    \end{macrocode}
%    For success in this case, we require the \pkg{aeb\_pro} package; \app{Acrobat} needs to load
%    and save the newly created PDF, created by either \app{distiller} or \app{ps2pdf}. The
%    \pkg{aeb\_pro} command \cs{declareImageAndPlacement} is used for this purpose. The command
%    \cs{IA@EndEmbedding@aebpro} is redefined to input an \env{execJS} environment, which will get things going.
%    \begin{macrocode}
\newcommand{\IA@embedIcon}[2][1]{\begingroup
  \declareImageAndPlacement{path=#2,#1}\endgroup}
%    \end{macrocode}
%    When \pkg{aeb\_pro} is loaded and a pdfmark-type driver is used, \cs{embedIcon} uses
%    \cs{declareImageAndPlacement} from \pkg{aeb\_pro} (see documentation of that package).
%    JavaScript methods embed the graphics files.
%    \begin{macrocode}
\def\IA@EndEmbedding@aebpro{\@bEmbedfalse\begingroup
  \IfFileExists{\jobname-exec.cut}{}
  {\immediate\openout\@auxout \jobname-exec.cut
  \immediate\write\@auxout{\string\begin{execJS}{IAexec}^^J%
  \string\insertPreDocAssembly^^J%
  \string\end{execJS}}}%
  \InputIfFileExists{\jobname-exec.cut}{}{}%
\endgroup}%
}{%
%    \end{macrocode}
%    The final case, we \cs{let} \cs{IA@embedIcon} to \cs{IA@embedIcon@null} to let the document
%    compile. A warning message is written to the log.
%    \begin{macrocode}
  \let\IA@embedIcon\IA@embedIcon@null
}
\fi\fi\fi
%    \end{macrocode}
%    \subsection{The \texorpdfstring{\cs{embedEPS}}{\textbackslash{embedEPS}} command}
%    \begin{macro}{\embedEPS}
%    \hskip-\marginparsep\texttt{[\ameta{KVPairs}]\darg{\ameta{path}}}
%    When a \psf{pdfmark}-type driver is being used, \cs{embedEPS} is \cs{let} to
%    \cs{IA@embedEPS}. This command is used to embed EPS files.
%    \begin{macrocode}
\newcommand\IA@embedEPS[2][]{\ifx\IA@Icons@pdfmark@Names\@empty
  \global\let\IA@Icons@pdfmark@Names\@gobble\fi
  \global\@EmbedEPSUsedtrue
  \begingroup\let\x\noexpand
  \setkeys*{IAKVfamily}{#1}%\XKV@rm has remaining keys
  \ifx\IAKVfamily@name\@empty\IA@handle@name@empty\fi
  \edef\@tmpexp{\x
    \IA@embedEPS@save[\XKV@rm]{embed\IAKVfamily@name}{#2}}\@tmpexp
  \edef\@tmpexp{\x\begin{createImage}{\x
    \bboxOf{embed\IAKVfamily@name}}{\IAKVfamily@name}
    \ifx\IAKVfamily@presp\@empty\else\IAKVfamily@presp\space\fi
    \IA@mark{embed\IAKVfamily@name} /SP pdfmark
    \ifx\IAKVfamily@postsp\@empty\else\space\IAKVfamily@postsp\fi
    \x\end{createImage}}%
  \toks@=\expandafter{\@tmpexp}%
  \edef\@tmpexp{\x\g@addto@macro\x
    \IA@CreateImage@xsp{\the\toks@}}\@tmpexp
%    \end{macrocode}
%     Create a list (\cs{IA@Icons@pdfmark@Names}) a list of all the names,
%     this is used to create an array of icon names (see the end of the file).
%    Also created is a token list of the icon names, this is employed
%    in the definition of \cs{IA@makeHiddenIconFlds} at the end of this file.
%    \begin{macrocode}
  \edef\y{\x\g@addto@macro\x
    \IA@Icons@pdfmark@Names{,"\IAKVfamily@name"}}\y
  \edef\y{\x\g@addto@macro\x
    \IA@Icons@pdfmark{{\IAKVfamily@name}}}\y
  \endgroup
}
%    \end{macrocode}
%    \end{macro}
%    Some warning messages when things go wrong.
%    \begin{macrocode}
\def\IA@WarningMsgStr{%
    A pdfmark driver used - dvips,\MessageBreak
    something's not right however:
    \if@EmbedIconUsed
      \@ifpackageloaded{aeb_pro}{}{\MessageBreak
        Use of \string\embedIcon\space
        requires the\MessageBreak aeb_pro package,
        or possibly use\MessageBreak
        a non-pdfmark driver}\fi
  \if@EmbedEPSUsed
    \@ifpackageloaded{graphicxsp}{}{\MessageBreak
      \string\embedEPS\space
      requires the graphicxsp package}\fi
  }
\def\IA@WarningMsg{\PackageWarningNoLine{icon-appr}{\IA@WarningMsgStr}}
\ifpdfmarkup
  \AtBeginDocument{%
    \if@EmbedIconUsed
      \@ifpackageloaded{aeb_pro}{}{\ifx\IA@WarningMsg\relax\else
        \IA@WarningMsg\let\IA@WarningMsg\relax\fi}\fi
    \if@EmbedEPSUsed
      \@ifpackageloaded{graphicxsp}{}{\ifx\IA@WarningMsg\relax\else
      \IA@WarningMsg\let\IA@WarningMsg\relax\fi}\fi}%
\else
    \AtBeginDocument{\if@EmbedEPSUsed
      \PackageWarningNoLine{icon-appr}{The use of \string\embedEPS\space
      not allowed\MessageBreak
      with \ifluatex lualatex\else\ifpdf pdflatex\else xetex\fi\fi}
    \fi}%
\fi
%    \end{macrocode}
%    \end{macro}
%    \leavevmode\DescribeMacro\IA@makeHiddenIconFlds
%    There is a final case of the  workflow, when
%    \cs{embedEPS} is used instead of \cs{embedIcon}. For \textbf{\textsf{pdfmark}},
%    the user has \app{Acrobat}, I'm assuming, and is not using \app{ps2pdf} without
%    \app{Acrobat}. Here, we create a series of hidden \cs{pushButtons} fields
%    each referencing one of the EPS embedded with \cs{embedEPS}; the creation
%    of these fields is encapsulated into the \cs{IA@makeHiddenIconFlds}.
%    \changes{v1.2.1}{2020/06/13}{Replaced \string\cs{ifpdfmarkup} with \string\cs{if@EmbedEPSUsed}.
%    Code should only be used if \string\cs{embedEPS} is used.}
%    \begin{macrocode}
\def\IA@makeHiddenIconFlds{\if@EmbedEPSUsed
  \edef\x{\noexpand\@tfor\noexpand\iName:=\IA@Icons@pdfmark}\x\do{%
   \smash{\rlap{\pushButton[\BC{}\BG{}\F\FHidden\TP{1}\S{S}
    \I{\csOf{\iName}}]{IAhidden.\iName}{0bp}{0bp}}}%
  }%
  \fi
}
%    \end{macrocode}
%    Insert \cs{IA@makdHiddenIconFlds} at the beginning of the document.
%    \begin{macrocode}
\AtBeginDocument{\IA@makeHiddenIconFlds}
%    \end{macrocode}
%    Finally, a document JavaScript is inserted into the document that
%    gets each of the fields created by \cs{IA@makeHiddenIconFlds},
%    and uses \texttt{\meta{Doc}.addIcon()} and \texttt{\meta{Field}.buttonGetIcon()}
%    to ``register'' these icons. We then delete the fields after we are finished with them.
%    \cs{IA@Icons@pdfmark@Names} will be either empty (\cs{embedEPS} is not used) or
%    expands to a list of icon names, for each use of \cs{embedEPS}.
%    \changes{v1.2.1}{2020/06/13}{\string\cs{IA@Icons@pdfmark@Names} is either empty
%    or expands to a list of icon names.}
%    \begin{macrocode}
\ifpdfmarkup
\begin{insDLJS}{aicons}{icon-appr: Add icons to Catalog > Names > AP}
var aIconNames= new Array(\IA@Icons@pdfmark@Names);
for (i=0; i< aIconNames.length; i++) {
  var f=this.getField("IAhidden."+aIconNames[i]);
  if (f!=null) {
    try{ this.addIcon(aIconNames[i],f.buttonGetIcon());
    this.removeField("IAhidden."+aIconNames[i]); }catch(e){};
  }
}
\end{insDLJS}
\fi
%</package>
%    \end{macrocode}
%  \Finale
\endinput