I've tried evince and a couple other the GPL PDF viewers, but they don't run Java correctly (and sometimes won't even use the form correctly).
I've tried opening it in Acrobat Professional, and changing the setting to "readable", but somehow, my JavaScript code gets corrupted.
I'm wondering if the problem is because I'm mixing {insdljs} with {hyperref}
Does anyone have any suggestions for somehow making this do what I want?
Below is a sample of some of the things I am trying to do:
(change borders on Open, do calculations, hide fields during print).
Code: Select all
\documentclass[12pt, letterpaper]{article}
\usepackage[pdftex,colorlinks=true,
pdftitle={Sample},
pdfsubject={Reader},
pdfauthor={Chris},
pdfpagemode=UseNone,
pdfstartview=FitH,
pagebackref,
pdfhighlight={/N}]
{hyperref}
\usepackage[pdftex]{insdljs}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% JAVA SCRIPT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\immediate\pdfobj{
<<
/WP << /S /JavaScript /JS (prePrint();) >>
/DP << /S /JavaScript /JS (postPrint();) >>
>>
}
\pdfcatalog{/AA \the\pdflastobj\space 0 R}
\begin{insDLJS}[charsheet]{charsheet}{Document Level JavaScript}
function onOpen() {
this.getField("Name").borderStyle = border.u;
}
function calc() {
this.getField("Sum").value = this.getField("One").value + this.getField("Two").value;
}
function prePrint(){
this.getField("One").hidden = true;
}
function postPrint(){
this.getField("One").hidden = false;
}
\end{insDLJS}
\OpenAction{/S /JavaScript /JS (onOpen();)}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DOCUMENT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{Form}
\begin{tabular}{l}
\TextField[name={Name}, charsize={14pt}, width={2.5in}, bordercolor={0 0 0}]{}
\end{tabular}
\vspace{1cm}
\begin{tabular}{lllll}
\TextField[name={Sum}, align=1, bordercolor={0 0 0}, readonly=true]{} & = &
\TextField[name={One}, align=1, bordercolor={0 0 0}]{} & + &
\TextField[name={Two}, align=1, bordercolor={0 0 0}]{}
\end{tabular}
\vspace{1cm}
\begin{minipage}{2in}
\PushButton[name=calculate, charsize=10pt, onclick={calc()}, bordercolor={0 0 1}] {Recalculate}
\end{minipage}
\end{Form}
\end{document}