summaryrefslogtreecommitdiff
path: root/Master/texmf-doc/doc/english/pdf-forms-tutorial-en/examples/ex0008.tex
blob: 373a7835a4f02f63a01efd10b64cea23a7dbdfb2 (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
\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}[exaaac]{exaaac}{Document Level JavaScript}

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

function willPrint()
{
  app.alert("The document will be printed.");
}

function didPrint()
{
  app.alert("The document was printed.");
}

// function to run when opening the document
function myFirstJavaScriptFunction()
{
  if(!done) {
    done = 1;
    app.alert("The form was opened.");
  }
}
\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}]{}\\
&\\*[-0.9em]\textforlabel{nn}{Name:}&%
\TextField[name=name,width=20em,%
bordercolor={0.65 0.79 0.94}]{}\\
&\\*[-0.9em]\textforlabel{ab}{Department:}&%
\ChoiceMenu[name=abt,width=20em,popdown=true,value=v,%
bordercolor={0.65 0.79 0.94}]{}{%
Sales=v,Production=f,Service=s}\\
&\\*[-0.9em]\hline
&\\*[-0.9em]\multicolumn{2}{|c|}{\textbf{Time}}\\
&\\*[-0.9em]\textforlabel{z}{Time:}&%
\ChoiceMenu[name=zeit,width=20em,popdown=true,value=u,%
bordercolor={0.65 0.79 0.94}]{}{%
unlimited=u,limited=b}\\
&\\*[-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}]{}\\
&\\*[-0.9em]\textforlabel{t1}{Ground floor:}&%
\CheckBox[name=e1,width=1.2em,%
bordercolor={0.65 0.79 0.94}]{}\\
&\\*[-0.9em]\textforlabel{t2}{First floor:}&%
\CheckBox[name=e2,width=1.2em,%
bordercolor={0.65 0.79 0.94}]{}\\
&\\
\hline
\end{tabular}
\end{Form}
\end{document}