summaryrefslogtreecommitdiff
path: root/Master/texmf-doc/doc/english/pdf-forms-tutorial-en/forms-src/fde0011.tex
blob: 7c1c2749c1cead2bc2742d3b95897d7feeade0a5 (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
The insdljs package is used to add document level JavaScript.
The package requires to specify the output driver.
\begin{lstlisting}
\usepackage[pdftex]{insdljs}
\end{lstlisting}
The JavaScript-code to add is placed in an
\textit{insDLJS\/} environment. The optional argument
and the first required argument must be \LaTeX{} identifiers
(use a string containing characters only, no numbers).
The second required argument is a comment
\begin{lstlisting}
\begin{insDLJS}[exaaaa]{exaaaa}{Document Level JavaScript}
// ... Place Java source code here ...
\end{insDLJS}
\end{lstlisting}
The identifier is used to build a file name (``exaaaa.djs'') to
temporarily store the packed JavaScript code.

The \textit{OpenAction\{\}\/} macro specifies a function which is executed
when the document is opened.
\begin{lstlisting}
\OpenAction{/S /JavaScript /JS (myFirstJavaScriptFunction();)}
\end{lstlisting}
The JavaScript-code is enclosed in brackets. The example code
contains a function invokation.

The function may be invoked multiple times (each time one navigates
to page 1). We use a variable as a flag indicating whether the
function is run for the first time or not.
\lstinputlisting{../examples/ex0006.tex}
A message box is shown when the document is opened. In the
german version the character \"{o} is malformed to
``\"{}o'' because the inputenc package replaces german
umlauts (and other characters) by the corresponding
\LaTeX{} code sequence. There are two ways to solve the problem:
\begin{itemize}
\item	Remove the inputenc package and convert german umlauts to their
\LaTeX{} code sequence manually (shown in the listing below at the end of this
section) or
\item	use JavaScript-Unicode notation for umlauts in JavaScript instead
of typing the umlauts directly (shown in section~\vref{sec:fde0020}).
\end{itemize}
\begin{lstlisting}
\usepackage[latin1]{inputenc}
\end{lstlisting}
from our source.
\lstinputlisting{../examples/ex0007.tex}