Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have been toying with the idea of converting some forms at work to interactive forms. I have tried some of the routines that come with insdljs, but they seem a bit dated. The idea is very attractive. I am looking for more recent information, links and pointers. Does Beamer use JavaScript?

share|improve this question

2 Answers 2

up vote 10 down vote accepted

A similar question was posted in the German newsgroup de.comp.text.tex recently.

With pdfLaTeX it is easy to add JavaScript at the document level. User defined JavaScript functions can be added as Action dictionaries (simple pdf objects) to the document. Then their names have to be mapped to the corresponding PDF object numbers in the /JavaScript name tree of the /Names dictionary in the PDF catalog using the pdfTeX primitive \pdfnames. Finally, the functions can be used within any PDF object that accepts an Action dictionary (links, widgets, pages, etc.). All this is documented in the PDF reference and in the JavaScript reference of Acrobat:

Here is a simple example which may serve as a starting point. Therein, doc-level JavaScript functions which accept arguments are used in the Action dictionaries of two links:

\documentclass{article}

\immediate\pdfobj{<<
  /S/JavaScript/JS (someFunc=function(arg){app.alert('I say ' + arg);})
>>}
\edef\someFunc{\the\pdflastobj\space 0 R}

\immediate\pdfobj{<<
  /S/JavaScript/JS (otherFunc=function(arg){app.alert('You say ' + arg);})
>>}
\edef\otherFunc{\the\pdflastobj\space 0 R}

\pdfnames{
  /JavaScript <<
    %name tree mapping doc. level JavaScript functions to object numbers
    /Names [(someFunc) \someFunc (otherFunc) \otherFunc ]
    /Limits [(otherFunc) (someFunc)] %first and last in alphab. order
  >>
}

\begin{document}
   \leavevmode
   \pdfstartlink user {
      /Subtype /Link
      /A <<
        /S/JavaScript
        /JS (someFunc('Hello!'))
      >>
   }Hello!\pdfendlink

   \leavevmode
   \pdfstartlink user {
      /Subtype /Link
      /A <<
        /S/JavaScript
        /JS (otherFunc('Good bye!'))
      >>
   }Good bye!\pdfendlink
\end{document}

Alexander

share|improve this answer
    
Alexander thanks for all the info. I have accepted your answer, as besides being the best to get you up to speed with some points! –  Yiannis Lazarides Sep 15 '10 at 8:58
    
Alexander, thanks for your great answer! I've edited it to include clickable links to the documentation you had posted. –  Juan A. Navarro Sep 15 '10 at 12:44

AFAIK, Beamer does not use JavaScript. I do not have a direct answer for LaTeX, but some pointers that might be useful.

ConTeXt provides a mechanism for including arbitrary JS. See the widgets manual for details. ConTeXt presentation modules (s-pre-60 onwards) also use JavaScript to sequentially displaying things on a page (unlike Beamer which creates multiple pages), as does Paul Isambert's lecturer package (which works for plain TeX, LaTeX, and ConTeXt).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.