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 would like to use LaTeX to produce a PDF document with forms with the following features: -One or two user-modifiable text fields -One output text field -A "run" button that, when pressed, will take the first fields, run calculations on it using a javascript function, and put the result in the output field.

So what packages would I need (I presume insdljs, but would I need anything else), where can I get them, and what would be the actual program to put into LaTeX. Thanks.

share|improve this question
    
Pure opinion: I think this is the future of TeX and of interactive documents generally: luatex.org which is part of wiki.contextgarden.net/Main_Page You'll have to learn Lua, but if you can use Javascript you shouldn't have any problems porting over. You'll also have to allow some time to get your installation up and running. They have some samples on their site; interactive PDFs-- nothing too exciting--kind of like Powerpoints, but the possibilities for development are rich with Lua. –  Joshua Cullick Jun 21 '12 at 7:56
    
The one page is about LuaTeX, the engine and the other page is about ConTeXt, the "format". Surely ConTeXt has rich build in support for JavaScript and interactive documents. –  topskip Jun 21 '12 at 8:55
    
See for example tex.stackexchange.com/questions/7869/… –  Yiannis Lazarides Jun 21 '12 at 9:18
    
I'm in the process of learning ConTeXt today. The last few hours I was installing and configuring it. LuaTeX is embedded in my ConTeXt installation, and the ConTeXt installation is embedded in my TeXLive installation. Still there was some configuring to do, and I haven't done any LuaTeX yet- mostly I'm working on Hebrew support, which I have got working. Not sure about Javascript in ConTeXt in particular but: tex.stackexchange.com/questions/3080/… is a good start –  Joshua Cullick Jun 21 '12 at 9:41
add comment

1 Answer

Take a look a the AcroTeX Education Bundle. The eforms package therein provides commands for creating JavaScript forms. If you want to reuse JavaScript code from form element to element you can use the insdljs package as you know about.

There are a ton of examples with source code at the AEB site. Here's a short demo:

\documentclass{article}
\usepackage[pdftex]{eforms}
\usepackage{insdljs}

\begin{insDLJS}{\jobname}{update the form}
function update() {
    var a = parseFloat(this.getField("A").value);
    var b = parseFloat(this.getField("B").value);
    this.getField("C").value = a*a+b;
}
\end{insDLJS}

\begin{document}
\begin{tabular}{rrr}
& $x$ & \textField{A}{1.5cm}{1.0cm} \\
& $y$ & \textField{B}{1.5cm}{1.0cm} \\
\pushButton[\CA{Calculate}\A{\JS{update();}}]{run}{1.5cm}{1.0cm}
& $x^2 + y$ & \textField{C}{1.5cm}{1.0cm}
\end{tabular}
\end{document}
share|improve this answer
    
Thanks, but while it seems to have a lot of advanced stuff, I can't find where (if anywhere) it describes how the basic syntax works for the button and text-field identification, which is really what I need. –  Yitzhak Kornbluth Jun 21 '12 at 0:11
    
I looked at the documentation there a bit more, and I think I found it. Thanks. –  Yitzhak Kornbluth Jun 21 '12 at 0:54
add comment

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.