[pdftex] [Resolved] Getting started with JavaScript and pdftex
Suresh Govindachar
sgovindachar at yahoo.com
Sat Mar 24 07:18:00 CET 2012
To write plain TeX code that will have JavaScript functions embedded in the
pdf created using pdfTeX, with the functions being callable via user clicks:
References: http://www.tug.org/TUGboat/tb22-3/tb72story.pdf, eforms.dtx and
insdljs.dtx (both .dtx from
http://tug.ctan.org/tex-archive/macros/latex/contrib/acrotex/)
Outline of implementaion:
1) To make a clickable link call a JavaScript function, use the following as
the "action":
<</S/JavaScript/JS(myHelloWorld();)>>
2) To embed a JavaScript into the pdf, add the following to the tex file
(for processing by pdftex):
\immediate\pdfobj {
<< /S /JavaScript /JS (function myHelloWorld()
{
app.alert("Hello World -- via TeX!", 3);
}
)
>> }
\xdef\objDLJS{\the\pdflastobj\space 0 R}
\immediate\pdfobj {%
<< /Names [(Doc Level JS) \objDLJS] >> }
\edef\objNames{\the\pdflastobj\space 0 R}
\pdfnames {/JavaScript \objNames}
Please consider updating the pdfTeX manual with some indication of embedding
and using JavaScript functions.
Thanks,
--Suresh
More information about the pdftex
mailing list