[Tex/LaTex] Losing check box entries when saving LaTeX-generated PDF form

formshyperrefpdftex

The code below implements a simple PDF form. Some PDF readers can save the form after it has been filled to a PDF with the new state. This works for the text entry whose entry is saved but the state of any checkbox is lost. Any remedy?

\documentclass{minimal}
\usepackage[pdftex]{hyperref}

\begin{document}
\begin{Form}
    \noindent
    \CheckBox[bordercolor={0 0 0},height=1ex,width=1.5ex,name=yes]{Yes}\quad
    \CheckBox[bordercolor={0 0 0},height=1ex,width=1.5ex,name=no]{No}\quad
    \TextField[name=textfield,width=3cm]{Text:}
\end{Form}
\end{document}

I noted on Mac OS X in the Preview.app that checking a check box alone does not lead the document to be considered as modified. Only entering text leads to a modified state and subsequently only a modified document can be saved. What is special about check boxes?

Maybe this is a reader issue and I would be interested to hear if the example above indeed works. There is a similar question How to get radio boxes right in PDF forms using hyperref? which was closed as off topic.

Edit: I have added name fields for the check boxes. On OS X with Preview.app this still does not solve the problem for me.

Best Answer

PDF forms are very similar to HTML forms. You need to add "name" for the CheckBoxes. this worked, when I tested it with Acrobat Pro.

enter image description here

\documentclass{minimal}
\usepackage[pdftex]{hyperref}
\begin{document}
\begin{Form}
    \noindent
    \CheckBox[bordercolor={0 0 0},height=1ex,width=1.5ex, name=ch1]{Yes}\quad
    \CheckBox[bordercolor={0 0 0},height=1ex,width=1.5ex, name=ch2]{No}\quad
    \TextField[name=textfield,width=3cm,value=default]{Text:}
\end{Form}
\end{document}

Any further processing must be done with JaVaScript. A good bundle of packages is provided by acrotex. The insdljs package provided by acrotex can be very useful for producing forms.

Related Question