1. Can someone please show me an example of how to include a simple Javascript form within a pdflatex document?

  2. Can someone please show me an example of accessing and modifying the PDF file's DOM from Javascript within a pdflatex document?

  3. Is there some reasonably friendly document to describe how to intermix PDF and Javascript?

  • 2
    AFAIK, you cannot edit the DOM of the PDF file (as there is no DOM as in HTML). See "Where Can You Use JavaScript?" in the JavaScript Manual "Acrobat JavaScript Object Specification"
    – topskip
    Oct 6 '11 at 16:52
  • @Werner: No typo, it's a form, as in "fill out", not from, as in "indicating the source".
    – doncherry
    Oct 6 '11 at 16:58
  • 1
    @doncherry: M'kay.
    – Werner
    Oct 6 '11 at 17:05
  • I wrote some javascript stuff. It seems there are ways to create new form elements - but no matter if Adobe provides DOM or any object model at all: documents generated by TeX do not enable such modifications. At least that's what I understood when I tried to use the API methods to crerate objects. Apparently, a document needs to be encrypted in order to create new objects. It is ok to modify existing objects, though (like text fields or buttons). Dec 16 '11 at 14:49

You might try the manual to the eforms package. eforms is another interface (other than hyperref) for creating PDF forms in TeX. The manual includes many simple examples.

There is no DOM in PDF. If you want parts of the PDF to change based on form events, you pretty much have to make those changing things read-only text fields.

For intermixing JavaScript and your TeX code see this demo of the insDLJS package

Both of the docs (and the packages they document) are written by D.P. Story, who is extremely prolific in this area. His acrotex bundle has many more examples.


Try the following tex file:

app.alert("HALLO WELT");

For more information, look at the official document!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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