\documentclass{article}
\usepackage[designiv,usetemplates]{web}
\usepackage{eforms}
\usepackage{graphicxsp}

%\previewMiKTeX

%\textBgColor{cornsilk}

\title{\textsf{GraphicxSP}\texorpdfstring{\\}{:} Forms}
\author{D. P. Story}
\university{Acro\negthinspace\TeX.Net}
\email{dpstory@acrotex.net}
\subject{Form XObjects and BP, EP and SP operators, transparency}
\keywords{Distiller, Form XObjects, BP, EP, and SP operators,transparency}

\newcommand{\cs}[1]{\texttt{\char`\\#1}}

\embedEPS[hiresbb,transparencyGroup]{AdobeDon}{graphics/AdobeDon}
\embedEPS{3Dcheck}{graphics/3Dcheck}
\embedEPS{3Dx}{graphics/3Dx}

% Normal,Multiply, Screen, Screen, Darken, Lighten, ColorDodge, ColorBurn, HardLight,
% SoftLight, Difference, Exclusion

\begin{createImage}{\bboxOf{3Dcheck}}{on3Dcheck}
    [ {3Dcheck} /SP pdfmark
\end{createImage}
\begin{createImage}{\bboxOf{3Dx}}{off3Dx}
    [ {3Dx} /SP pdfmark
\end{createImage}

\begin{createImage}{\bboxOf{AdobeDon}}{nAdobeDon}
    [ {AdobeDon} /SP pdfmark
\end{createImage}

\begin{createImage}{\bboxOf{AdobeDon}}{dAdobeDon}
    [ /ca .3 /SetTransparency pdfmark
    [ {AdobeDon} /SP pdfmark
\end{createImage}

\begin{createImage}{\bboxOf{AdobeDon}}{rAdobeDon}
    [ /ca .5 /SetTransparency pdfmark
    [ {AdobeDon} /SP pdfmark
\end{createImage}

\begin{createImage}{0 0 100 100}{xO}
.7529 setgray 0 0 100 100 rectfill 1 setgray 2 2 moveto 2 98 lineto 98 98 lineto
96 96 lineto 4 96 lineto 4 4 lineto fill 0.34 setgray 98 98 moveto 98 2 lineto
2 2 lineto 4 4 lineto 96 4 lineto 96 96 lineto fill
0 setgray 22.5 22.5 moveto 1 0 0 setrgbcolor /Helvetica 72 selectfont (O) show
\end{createImage}

\begin{createImage}{0 0 100 100}{xX}
.7529 setgray 0 0 100 100 rectfill 1 setgray 2 2 moveto 2 98 lineto 98 98 lineto
96 96 lineto 4 96 lineto 4 4 lineto fill 0.34 setgray 98 98 moveto 98 2 lineto
2 2 lineto 4 4 lineto 96 4 lineto 96 96 lineto fill
0 setgray 27 22.5 moveto 0 0 1 setrgbcolor /Helvetica 72 selectfont (X) show
\end{createImage}

\parindent0pt
\setlength{\fboxsep}{0pt}

\begin{insDLJS}[_setApp]{setapp}{Turn off highlighting}
var _setApp = true;
try { app.runtimeHighlight=false } catch(e) {};
\end{insDLJS}

\begin{document}

\maketitle

In the preamble, we make the following definitions: We embed for EPS
files, one of which are set a transparency group:
{\small\begin{verbatim}
\embedEPS[hiresbb,transparencyGroup]{AdobeDon}{graphics/AdobeDon}
\embedEPS{3Dcheck}{graphics/3Dcheck}
\embedEPS{3Dx}{graphics/3Dx}
\end{verbatim}
}
We also use the \texttt{createImage} environment to create more images, some new, others made
from the embedded files.\medskip

Create variations on \texttt{AdobeDon} by giving the image various degrees of opacity:
\begin{scriptsize}
\begin{verbatim}
\begin{createImage}{\bboxOf{AdobeDon}}{nAdobeDon}   % normal appearance
    [ {AdobeDon} /SP pdfmark
\end{createImage}

\begin{createImage}{\bboxOf{AdobeDon}}{dAdobeDon}   % down appearance
    [ /ca .3 /SetTransparency pdfmark
    [ {AdobeDon} /SP pdfmark
\end{createImage}

\begin{createImage}{\bboxOf{AdobeDon}}{rAdobeDon}   % rollover appearance
    [ /ca .5 /SetTransparency pdfmark
    [ {AdobeDon} /SP pdfmark
\end{createImage}
\end{verbatim}
\end{scriptsize}


\newpage

Now create two new graphic images using raw PostScript. In all cases we use
the \texttt{createImage} environment, first optional argument is the bounding box,
the second is the symbolic name for the graphic. The symbolic name can be used
in the \cs{includegraphics} command or the \cs{insertEPS} command.

\begin{scriptsize}
\begin{verbatim}
\begin{createImage}{0 0 100 100}{xO}
.7529 setgray 0 0 100 100 rectfill 1 setgray 2 2 moveto 2 98 lineto 98 98 lineto
96 96 lineto 4 96 lineto 4 4 lineto fill 0.34 setgray 98 98 moveto 98 2 lineto
2 2 lineto 4 4 lineto 96 4 lineto 96 96 lineto fill
0 setgray 22.5 22.5 moveto 1 0 0 setrgbcolor /Helvetica 72 selectfont (O) show
\end{createImage}

\begin{createImage}{0 0 100 100}{xX}
.7529 setgray 0 0 100 100 rectfill 1 setgray 2 2 moveto 2 98 lineto 98 98 lineto
96 96 lineto 4 96 lineto 4 4 lineto fill 0.34 setgray 98 98 moveto 98 2 lineto
2 2 lineto 4 4 lineto 96 4 lineto 96 96 lineto fill
0 setgray 27 22.5 moveto 0 0 1 setrgbcolor /Helvetica 72 selectfont (X) show
\end{createImage}
\end{verbatim}
\end{scriptsize}

Subsequent pages demonstrate how to use these images in the context of form fields.

Here are more traditional uses for a checkbox, but this time using
custom checks and crosses.

\medskip
\noindent\hspace*{20pt}\resizebox{11bp}{!}{\checkBox[%
    \A{\JS{%
        var f = this.getField("reportCk");\r
        f.value = !!event.target.isBoxChecked(0);\t
        this.dirty=false;
    }}
    \V{Off}\DV{Off}\AS{Off}\H{N}\autoCenter{n}
    \AP{/N << /Yes {xX} /Off {xO} >> }
]{ckBoxXO}{\widthOf{xX}bp}{\heightOf{xX}bp}{Yes}}
\textField[\Q1\Ff\FfReadOnly\autoCenter{n}]{reportCk}{.5in}{11bp}

\smallskip
\noindent\hspace*{20pt}\resizebox{11bp}{!}{\checkBox[%
    \A{\JS{%
        var f = this.getField("reportCk3D");\r
        f.value = !!event.target.isBoxChecked(0);\r
        this.dirty=false;
    }}
    \V{Off}\DV{Off}\AS{Off}\H{N}\autoCenter{n}
    \AP{/N << /Yes {on3Dcheck} /Off {off3Dx} >> }
]{ckBox3D}{\widthOf{3Dcheck}bp}{\heightOf{3Dcheck}bp}{Yes}}
\textField[\Q1\Ff\FfReadOnly\autoCenter{n}]{reportCk3D}{.5in}{11bp}

\medskip The verbatim listing of the second check box is, for example,
\begin{small}
\begin{verbatim}
\resizebox{11bp}{!}{\checkBox[%
    \A{\JS{%
        var f = this.getField("reportCk3D");\r
        f.value = !!event.target.isBoxChecked(0);\r
        this.dirty=false;
    }}
    \V{Off}\DV{Off}\AS{Off}\H{N}\autoCenter{n}
    \AP{/N << /Yes {on3Dcheck} /Off {off3Dx} >> }
]{ckBox3D}{\widthOf{3Dcheck}bp}{\heightOf{3Dcheck}bp}{Yes}}
\textField[\Q1\Ff\FfReadOnly\autoCenter{n}]{reportCk3D}{.5in}{11bp}
\end{verbatim}
\end{small}

We use \cs{resizebox} from the \textsf{graphicx} package to adjust
the sizes of the appearances.

\newpage


One last example, this one uses transparency. We now we create a push
button with the face of AdobeDon as the normal appearance (somewhat
paradoxically), AdobeDon at 50\% opacity for the rollover
appearance, and AdobeDon at 30\% for the down appearance. Will it
work, we'll see:\medskip

Push button: \raisebox{-3pt}{\resizebox{.5in}{!}{\pushButton[%
    \autoCenter{n}\BC{}\S{S}
    \A{\JS{app.alert("AcroTeX rocks the world!"); this.dirty=false;}}
    \I{nAdobeDon}\RI{dAdobeDon}\IX{rAdobeDon}\TP{1}\FB{true}
]{pbAdobeDon}{\widthOf{AdobeDon}bp}{\heightOf{AdobeDon}bp}}}


\medskip The verbatim listing is
\begin{small}
\begin{verbatim}
Push button: \raisebox{-3pt}{\resizebox{.5in}{!}{\pushButton[%
    \autoCenter{n}\BC{}\S{S}
    \A{\JS{app.alert("AcroTeX rocks the world!");
       this.dirty=false;}}
    \I{nAdobeDon}\RI{dAdobeDon}\IX{rAdobeDon}\TP{1}\FB{true}
]{pbAdobeDon}{\widthOf{AdobeDon}bp}{\heightOf{AdobeDon}bp}}}
\end{verbatim}
\end{small}

\end{document}
