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.
  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?

share|improve this question
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). –  Christian Feuersänger Dec 16 '11 at 14:49

2 Answers 2

up vote 5 down vote accepted

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.

share|improve this answer

Try the following tex file:

\documentclass{article}
\usepackage[pdftex]{insdljs}
\OpenAction{\JS{%
app.alert("HALLO WELT");
}}     
\begin{document}
THIS DOCUMENT IS A DOCUMENT
\end{document}

For more information, look at the official document!

share|improve this answer
    
There is also an example at tex.stackexchange.com/questions/8918/hello-world-in-pdflatex –  Yiannis Lazarides Dec 16 '11 at 10:07

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.