% compile with pdflatex, lualatex, or xelatex
\documentclass{article}
%\usepackage[designv]{web}
\usepackage[%
    web={designi},
    useacrobat
]{aeb_pro}
\usepackage{icon-appr}[2020/06/05]
\usepackage{hologo}

% uncomment next line to see the positions of other form fields within your PDF viewer (such as SumatraPDF)
%\previewOn\pmpvOn

\title{Creating icon appearances for form buttons using\texorpdfstring{\\}{}
  \textsf{pdflatex}, \textsf{lualatex}, and \textsf{xelatex}}
\author{D. P. Story}
\university{Acro\TeX.Net}
\email{dpstory@acrotex.net}
\subject{Techniques for creating button appearances}
\keywords{icon appearances of form buttons}
\version{1.0}
\norevisionLabel

\optionalPageMatter{%
    \begin{center}\fcolorbox{red}{webyellow}{%
    \begin{minipage}{.67\linewidth}
      Icon appearance images for the buttons of this document were produced by \ifluatex
      \hologo{LuaLaTeX}\else\ifpdf\hologo{pdfLaTeX}\else\ifxetex\hologo{XeLaTeX}\else
      an unsupported driver (\textsf{aeb\_pro} needed)\fi\fi\fi.
    \end{minipage}}
    \end{center}
}

\begin{embedding}
\embedIcon[name=mani]{graphics/man1.pdf}
\embedIcon[name=girl]{graphics/girl.pdf}
\embedIcon[name=scot]{graphics/scot.pdf}
\end{embedding}

\begin{document}

\maketitle

\section{Push Buttons}

We produce two push buttons, the second one is a re-scaling of the first.\medskip

\noindent\pushButton[%
%  \A{\JS{app.alert("AcroTeX rocks!")}}
  \TP{1}\BG{}\S{S}
  \I{\csOf{mani}}
  \RI{\girl}
  \IX{\scot}
]{myButton}{100bp}{100bp}
\qquad
\pushButton[%
  \TP{1}\BG{}\S{S}
  \I{\mani}
  \RI{\girl}
  \IX{\scot}
]{myButton1}{50bp}{50bp*\ratio{100bp}{100bp}}\vcgBdry[12pt]

\noindent The push buttons are properly produced for all drivers
(\textsf{pdflatex}, \textsf{lualatex}, and \textsf{xelatex}) and can be
viewed, with full functionality, in \textsf{Acrobat}, \textsf{Adobe Reader},
\textsf{PDF-XChange Viewer}, and \textsf{PDF-XChange Editor}. All buttons, including
the ones on the next page can be viewed in \textsf{SumatraPDF}, without any functionality.

\section{Check box and Radio Button Fields}

Similar techniques are made for check box and radio button fields;
however, \emph{there is one caveat}, the icon faces do not appear when the
file is first viewed in \textsf{PDF-XChange Editor}.\footnote{If you are
using that viewer.} You must first open the file in \textsf{Adobe Reader DC}
or \textsf{Acrobat}, and save it. The file then views properly in
\textsf{PDF-XChange Editor}, \emph{but not in} \textsf{PDF-XChange Viewer},
however.\vcgBdry[6pt]

Checkbox:
\checkBox[\BC{}\BG{}
    \V{Off}\DV{Off}\AS{Off}\H{N}\autoCenter{y}
    \AP{\N{\On{Man}{\mani}\Off{\girl}}}
    ]{myCkBx}{22bp}{22bp}{Man}\quad(Girl is `off', Man is `on')\vcgBdry[6pt]

Radio Button Fields: \radioButton[\BC{}\BG{}
    \V{Off}\DV{Off}\AS{Off}\H{N}\autoCenter{y}
    \AP{\N{\On{Man1}{\mani}\Off{\girl}}}
    ]{myRadBtn}{22bp}{22bp}{Man1}\quad \radioButton[\BC{}\BG{}
    \V{Off}\DV{Off}\AS{Off}\H{N}\autoCenter{y}
    \AP{\N{\On{Man2}{\mani}\Off{\girl}}}
    ]{myRadBtn}{22bp}{22bp}{Man2}\quad\radioButton[\BC{}\BG{}
    \V{Off}\DV{Off}\AS{Off}\H{N}\autoCenter{y}
    \AP{\N{\On{Man3}{\mani}\Off{\girl}}}
    ]{myRadBtn}{22bp}{22bp}{Man3}\quad(Girl is `off', Man is `on')\vcgBdry[6pt]

\pushButton[\CA{Reset}\A{\JS{this.resetForm();}}]{reset}{}{11bp}\vcgBdry[6pt]

\newpage

\section{Icons in this document}

Use the button below to cycle through all icons in this document.

\begin{defineJS}{\cycleJS}
if (typeof indexIcon == "undefined") var indexIcon=0;
var oIconName=this.icons[indexIcon].name;
var f=this.getField("iconContainer");
var oIcon=this.getIcon(oIconName);
f.buttonPosition=position.iconTextV;
f.buttonSetIcon(oIcon);
f.buttonSetCaption(oIconName);
indexIcon = (indexIcon+1) \% (this.icons.length);
\end{defineJS}
% define a clear button feature, it clears the button iconContainer
% so it no longer displays an icon; pressing the Cycle button resumes
% the display as before.
\begin{defineJS}{\clearJS}
f=this.getField("iconContainer")
// save
var sv=f.buttonPosition;
var cptn=f.buttonGetCaption();
// clear
f.buttonPosition=position.textOnly;
f.buttonSetCaption("");
\end{defineJS}

\begin{center}
\pushButton[\BG{}\TP{2}\S{S}]{iconContainer}{100bp}{100bp}\vcgBdry[6bp]
\pushButton[\CA{Cycle}\AAmouseup{\cycleJS}]{cycleBtn}{}{11bp}\cgBdry[3bp]
\pushButton[\CA{Clear}\AAmouseup{\clearJS}]{clearBtn}{}{11bp}
\end{center}

\end{document} 