summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/pdf-forms-tutorial-en/examples/ex0012.tex
blob: b910505e063a99dcd04b1ffd10fb3d0b83b8b723 (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
\documentclass[ngerman,a4paper]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{mathptmx}
\usepackage[scaled=.92]{helvet}
\usepackage{courier}
\renewcommand*{\familydefault}{phv}
\usepackage[left=25mm,top=25mm,bottom=10mm,right=10mm]{geometry}
\usepackage{fancyhdr}
\lhead{ABC, Inc.}\chead{}\rhead{XYZ Dept.}
\lfoot{}\cfoot{}\rfoot{}
\pagestyle{fancy}
\usepackage{graphicx}
\usepackage{color}
\usepackage[
  pdftex,a4paper=true,colorlinks=true,
  pdftitle={Key form},pdfsubject={Key},
  pdfauthor={ich},
  pdfpagemode=UseNone,pdfstartview=FitH,
  pagebackref,pdfhighlight={/N}
]{hyperref}
\usepackage[pdftex]{insdljs}
\immediate\pdfobj {
<<
  /WP << /S /JavaScript /JS (willPrint();) >>
  /DP << /S /JavaScript /JS (didPrint();) >>
>>
}
\pdfcatalog{/AA \the\pdflastobj\space 0 R}
\begin{insDLJS}[exaaae]{exaaae}{Document Level JavaScript}

// indicate that the function was not yet run
var done = 0;

function colorsPrinting()
{
  this.getField("vorname").fillColor = color.white;
  this.getField("name").fillColor = color.white;
  this.getField("abt").fillColor = color.white;
  this.getField("zeit").fillColor = color.white;
  this.getField("from").fillColor = color.white;
  this.getField("until").fillColor = color.white;
  this.getField("ht").fillColor = color.white;
  this.getField("e1").fillColor = color.white;
  this.getField("e2").fillColor = color.white;

  this.getField("vorname").strokeColor = color.black;
  this.getField("name").strokeColor = color.black;
  this.getField("abt").strokeColor = color.black;
  this.getField("zeit").strokeColor = color.black;
  this.getField("from").strokeColor = color.black;
  this.getField("until").strokeColor = color.black;
  this.getField("ht").strokeColor = color.black;
  this.getField("e1").strokeColor = color.black;
  this.getField("e2").strokeColor = color.black;

  this.getField("vorname").textFont = font.Helv;
  this.getField("name").textFont = font.Helv;
  this.getField("abt").textFont = font.Helv;
  this.getField("zeit").textFont = font.Helv;
  this.getField("from").textFont = font.Helv;
  this.getField("until").textFont = font.Helv;
  this.getField("from").textColor = color.black;
  this.getField("until").textColor = color.black;
}

function colorsScreen()
{

  var newcolor = [ "RGB", 0.65, 0.79, 0.94];
  this.getField("vorname").fillColor = newcolor;
  this.getField("name").fillColor = newcolor;
  this.getField("abt").fillColor = newcolor;
  this.getField("zeit").fillColor = newcolor;
  this.getField("from").fillColor = newcolor;
  this.getField("until").fillColor = newcolor;
  this.getField("ht").fillColor = newcolor;
  this.getField("e1").fillColor = newcolor;
  this.getField("e2").fillColor = newcolor;

  this.getField("vorname").strokeColor = newcolor;
  this.getField("name").strokeColor = newcolor;
  this.getField("abt").strokeColor = newcolor;
  this.getField("zeit").strokeColor = newcolor;
  this.getField("from").strokeColor = newcolor;
  this.getField("until").strokeColor = newcolor;
  this.getField("ht").strokeColor = newcolor;
  this.getField("e1").strokeColor = newcolor;
  this.getField("e2").strokeColor = newcolor;

  this.getField("vorname").textFont = font.HelvB;
  this.getField("name").textFont = font.HelvB;
  this.getField("abt").textFont = font.HelvB;
  this.getField("zeit").textFont = font.HelvB;
  this.getField("from").textFont = font.HelvB;
  this.getField("from").textColor = color.black;
  this.getField("until").textColor = color.black;
  this.getField("until").textFont = font.HelvB;
}

function validateTime()
{
  this.delay = true;
  if((event.value == "u") || (event.value == "unlimited")) {
    this.getField("from").display = display.hidden;
    this.getField("until").display = display.hidden;
  } else {
    this.getField("from").display = display.visible;
    this.getField("until").display = display.visible;
    this.getField("from").setFocus();
  }
  this.delay = false;
}

function willPrint()
{
  this.delay = true;
  colorsPrinting();
  this.delay = false;
}

function didPrint()
{
  this.delay = true;
  colorsScreen();
  this.delay = false;
}

// function to run when opening the document
function myFirstJavaScriptFunction()
{
  if(!done) {
    done = 1;
    this.delay = true;
    colorsScreen();
    this.getField("abt").currentValueIndices = 0;
    this.getField("abt").editable = true;
    this.getField("zeit").currentValueIndices = 0;
    this.getField("vorname").setFocus();
    this.delay = false;
  }
}
\end{insDLJS}
\OpenAction{/S /JavaScript /JS (myFirstJavaScriptFunction();)}
\newcommand{\textforlabel}[2]{%
\TextField[name={#1},value={#2},width=7em,align=2,%
bordercolor={1 1 1},readonly=true]{}%
}
\begin{document}
\section*{Request for a key}
\begin{Form}
\begin{tabular}{|rl|}
\hline
&\\*[-0.9em]\multicolumn{2}{|c|}{\textbf{Employee}}\\
&\\*[-0.9em]\textforlabel{vn}{First name:}&%
\TextField[name=vorname,width=20em,%
bordercolor={0.65 0.79 0.94}]{}~\pdfannot width 20pt {
	/Subtype /Text
	/T (First name)
	/C [0.65 0.79 0.94]
	/Name /Help
	/Contents (Please enter your surname here.)
}\(\qquad\)\\
&\\*[-0.9em]\textforlabel{nn}{Name:}&%
\TextField[name=name,width=20em,%
bordercolor={0.65 0.79 0.94}]{}~\pdfannot width 20pt {
	/Subtype /Text
	/T (Name)
	/C [0.65 0.79 0.94]
	/Name /Help
	/Contents (Please enter your name here.)
}\(\qquad\)\\
&\\*[-0.9em]\textforlabel{ab}{Department:}&%
\ChoiceMenu[name=abt,width=20em,popdown=true,combo=true,value=v,%
bordercolor={0.65 0.79 0.94}]{}{%
Sales=v,Production=f,Service=s}~\pdfannot width 20pt {
	/Subtype /Text
	/T (Department)
	/C [0.65 0.79 0.94]
	/Name /Help
	/Contents (Please choose your department. If your department is not yet listed, please enter the department name.)
}\(\qquad\)\\
&\\*[-0.9em]\hline
&\\*[-0.9em]\multicolumn{2}{|c|}{\textbf{Time}}\\
&\\*[-0.9em]\textforlabel{z}{Time:}&%
\ChoiceMenu[name=zeit,width=20em,popdown=true,value=u,%
validate={validateTime();},%
bordercolor={0.65 0.79 0.94}]{}{%
unlimited=u,limited=b}~\pdfannot width 20pt {
	/Subtype /Text
	/T (Time)
	/C [0.65 0.79 0.94]
	/Name /Help
	/Contents (Please choose to obtain the key for a limited or unlimited time. If you choose "limited" you have to specify start and end date too.)
}\(\qquad\)\\
&\\*[-0.9em]\textforlabel{v}{from:}&%
\TextField[name=from,width=10em,%
bordercolor={0.65 0.79 0.94}]{}\\
&\\*[-0.9em]\textforlabel{b}{until:}&%
\TextField[name=until,width=10em,%
bordercolor={0.65 0.79 0.94}]{}\\
&\\*[-0.9em]\hline
&\\*[-0.9em]\multicolumn{2}{|c|}{%
\textbf{Doors}}\\
&\\*[-0.9em]\textforlabel{th}{Front door:}&%
\CheckBox[name=ht,width=1.2em,%
bordercolor={0.65 0.79 0.94}]{}~\pdfannot width 20pt {
	/Subtype /Text
	/T (Front door)
	/C [0.65 0.79 0.94]
	/Name /Help
	/Contents (Please activate this checkbox to obtain a key opening the front door.)
}\(\qquad\)\\
&\\*[-0.9em]\textforlabel{t1}{Ground floor:}&%
\CheckBox[name=e1,width=1.2em,%
bordercolor={0.65 0.79 0.94}]{}~\pdfannot width 20pt {
	/Subtype /Text
	/T (Ground floor)
	/C [0.65 0.79 0.94]
	/Name /Help
	/Contents (Please activate this checkbox to obtain a key opening the ground floor.)
}\(\qquad\)\\
&\\*[-0.9em]\textforlabel{t2}{First floor:}&%
\CheckBox[name=e2,width=1.2em,%
bordercolor={0.65 0.79 0.94}]{}~\pdfannot width 20pt {
	/Subtype /Text
	/T (First floor)
	/C [0.65 0.79 0.94]
	/Name /Help
	/Contents (Please activate this checkbox to obtain a key opening the first floor.)
}\(\qquad\)\\
&\\
\hline
\end{tabular}
\end{Form}
\end{document}