# [pdftex] how to implement global JavaScript functions using pdfLaTeX

D. P. Story story at uakron.edu
Fri Sep 14 14:30:06 CEST 2001

The Acrobat JavaScript Object Specification spells out how
to define global variables.  There are several types.

If you define a variable in the document level section, perhaps
inserted by my insDLJS, you get a variable known to the entire document
including the fields; for example, if you says,

\usepackage[pdftex]{insdljs}
\begin{insDLSJ}{myDLJS}{My Private DLJS}
var x = 1;
var y;
global.z = 2;
function myFunc(a,b)
{
return a+b;
}
\end{insDLJS}

The variables x and y will be known throughout the document. I use this
technique in the Exerquiz package to create variables that are used to
globally store data. The variable global.z is known throughout the document,
and throughout the Acrobat/Reader session. Other documents that are later
loaded will know the value of global.z, but not know the values of x or y.

You can also set variables to be persistent, they would be known across

Hope this helps.

dps

On 14 Sep 2001, at 16:59, Dr. Thomas Risse wrote:

> Hi,
>
> I use pdfTeX 14f with hyperref 6.70m, Babel 3.6z ... and I
> don't know how to implement  g l o b a l  JS functions in TeX.
> I don't want to have to use the Adobe Acrobat Writer
>     tools -> forms -> document-JS ... to insert a global
> JavaScript function into each new version of some
> pdf-document generated by pdfLaTeX.
> Instead, I would like to specify the global function
> in the source TeX-file. I could not find any  w o r k i n g
> example with source in the web or hints in this list
> except maybe D.P:Story's insDLJS.
>
> Is there a canonical way to embed global JS functions
> (specified in the source file) into pdf documents?
> Any hint appreciated, Thomas
>
> PS
> I was very much impressed by Hans Hagens calculat.pdf
> which led to the idea to implement some interactive numeric
> algorithms in my lecture notes for mathematics.
> After some problems especially with multi linguality
> I came up with an english/german version of basic numerics
> http://www.weblearn.hs-bremen.de/risse/MAI/docs/numerics.pdf
> http://www.weblearn.hs-bremen.de/risse/MAI/docs/numerik.pdf
>
> --
> Thomas Risse, Informatik
> Hochschule Bremen
> Neustadtswall 30, 28199 Bremen, Germany
> fon +49 (0) 421/5905-3425, fax +49 (0) 421/5905-3476
> risse at hs-bremen.de
> www.weblearn.hs-bremen.de/risse
>
>
>
> --- StripMime Report -- processed MIME parts ---
> multipart/alternative
>   text/plain (text body -- kept)
>   text/html
> ---
> _______________________________________________
> pdftex mailing list
> pdftex at tug.org
> http://tug.org/mailman/listinfo/pdftex
>

Dr. D. P. Story / dpstory at uakron.edu / (330) 972-7514
http://www.math.uakron.edu/~dpstory/ Dept of Mathematics
and Computer Science / University of Akron / Akron, Ohio 44325
AcroTeX Web Site: http://www.math.uakron.edu/~dpstory/acrotex.html
Site Includes: e-Calculus, Algebra Review in Ten Lessons,