summaryrefslogtreecommitdiff
path: root/texmf-dist/doc/latex/graphicxsp/examples/grxsp_forms_aeb.tex
blob: 675c6b5bb2a13233b51d82aa3ad18b9ab57be3fa (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
\documentclass{article}
\usepackage[designiv,usetemplates]{web}
\usepackage{eforms}
\usepackage{graphicxsp}
\usepackage{fancyvrb}

%\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}}
\let\pkg\textsf

\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}[fontsize=\small]
\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{Verbatim}[fontsize=\scriptsize]
\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}


\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{Verbatim}[fontsize=\scriptsize]
\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}
Subsequent pages demonstrate how to use these images in the context of form fields.\medskip

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

\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}\cgBdry[6pt]
\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{Verbatim}[fontsize=\small,commandchars=!()]
\resizebox{11bp}{!}{\checkBox[\A{\JS{(!normalfont!itshape(JS code not shown))}}
    \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}
We use \cs{resizebox} from the \textsf{graphicx} package to adjust
the sizes of the appearances.\medskip

For \pkg{eforms} dated 2018/11/27 or later, the above check box code can be simplified
as follows:
\begin{Verbatim}[fontsize=\small,commandchars=!()]
\resizebox{11bp}{!}{\checkBox[\A{\JS{(!normalfont!itshape(JS code not shown))}}
    \V{Off}\DV{Off}\AS{Off}\H{N}\autoCenter{n}
    \AP{\N{\On{Yes}{\on3Dcheck}\Off{\off3Dx}}}
]{ckBox3D}{\widthOf{3Dcheck}bp}{\heightOf{3Dcheck}bp}{Yes}}
\textField[\Q1\Ff\FfReadOnly\autoCenter{n}]{reportCk3D}{.5in}{11bp}
\end{Verbatim}
\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{y}\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}[fontsize=\small]
Push button: \raisebox{-3pt}{\resizebox{.5in}{!}{\pushButton[%
    \autoCenter{y}\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}