[pdftex] [Resolved] Getting started with JavaScript and pdftex

Paul Isambert zappathustra at free.fr
Sat Mar 24 08:36:58 CET 2012


Suresh Govindachar <sgovindachar at yahoo.com> a écrit:
> 
> 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}

I'd recommend my own Navigator package to handle that.

> Please consider updating the pdfTeX manual with some indication of embedding
> and using JavaScript functions.

There are tons of things you can do with PDF code. PDFTeX only gives you
the possibility to create that code properly (except in some cases like
bookmarks, where it does much more). Using JavaScript depends on your
knowledge of PDF, on which PDFTeX is somehow agnostic. If the manual
starts mentioning JavaScript, then it should logically mention graphic
operations, tagging, etc.

Best,
Paul



More information about the pdftex mailing list