<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">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
&amp;\\*[-0.9em]\multicolumn{1}{|c|}{\textbf{Key}}&amp;\multicolumn{1}{c|}{\textbf{Event}}\\
\hline
&amp;\\*[-0.9em]/WP&amp;The document will be printed.\\
\hline
&amp;\\*[-0.9em]/DP&amp;The document was printed.\\
\hline
&amp;\\*[-0.9em]/WS&amp;The document will be saved.\\
\hline
&amp;\\*[-0.9em]/DS&amp;The document was saved.\\
\hline
&amp;\\*[-0.9em]/DC&amp;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{
&lt;&lt;
  /WP &lt;&lt; /S /JavaScript /JS (willPrint();) &gt;&gt;
  /DP &lt;&lt; /S /JavaScript /JS (didPrint();) &gt;&gt;
&gt;&gt;
}
\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}
</pre></body></html>