summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/pdf-forms-tutorial-en/forms-src/fde0012.tex
blob: 8cd70d6ebd1839f17d40aedd449ceb2328deec79 (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
To process document events we have to add an /AA entry to the
\textsc{pdf} catalogue. The entry value must be a dictionary
defining event handlers. Entries in this dictionary
are key/value pairs, the value is again a dictionary
specifying the action to take.\\
The following keys can occur:\\[0.5em]
\begin{tabular}{|r|l|}
\hline
&\\*[-0.9em]\multicolumn{1}{|c|}{\textbf{Key}}&\multicolumn{1}{c|}{\textbf{Event}}\\
\hline
&\\*[-0.9em]/WP&The document will be printed.\\
\hline
&\\*[-0.9em]/DP&The document was printed.\\
\hline
&\\*[-0.9em]/WS&The document will be saved.\\
\hline
&\\*[-0.9em]/DS&The document was saved.\\
\hline
&\\*[-0.9em]/DC&The document will be closed.\\
\hline
\end{tabular}\\[0.5em]
In the example we run \textit{willPrint();\/} for the WillPrint event
and \textit{didPrint();\/} for the DidPrint event.
\begin{lstlisting}
\immediate\pdfobj{
<<
  /WP << /S /JavaScript /JS (willPrint();) >>
  /DP << /S /JavaScript /JS (didPrint();) >>
>>
}
\pdfcatalog{/AA \the\pdflastobj\space 0 R}
\end{lstlisting}
Before and after printing ex0008.pdf a message box is shown.
\lstinputlisting{../examples/ex0008.tex}
In ex0009.pdf we change stroke and fill colors and text fonts before
and after printing.
We have to change the
\textit{fillColor\/}, \textit{strokeColor\/}
and \textit{textFont\/} attributes.\\
The changes are enclosed in
\begin{lstlisting}
  this.delay = true
  // ...
  this.delay = false
\end{lstlisting}
to avoid multiple screen refreshes after each change.

In \textit{myFirstJavaScriptFunction()\/} we set defaults for the
choice lists
\textit{abt\/} and \textit{zeit\/} using:
\begin{lstlisting}
this.getField("abt").currentValueIndices = 0;
this.getField("zeit").currentValueIndices = 0;
\end{lstlisting}
We set the focus to the \textit{vorname\/} field by:
\begin{lstlisting}
this.getField("vorname").setFocus();
\end{lstlisting}
\lstinputlisting{../examples/ex0009.tex}