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.

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.

share|improve this question
1  
They seem to be working with Adobe Pro on Windows 7, although it came up with ...fixing form fields when it loaded the document. You also need to add names for the checkboxes. Any processing must be done with JavaScript. –  Yiannis Lazarides Jan 21 '12 at 11:22
add comment

1 Answer

up vote 4 down vote accepted

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.

share|improve this answer
    
Adding the name field does not solve the problem with Preview.app on OSX for me but I can see that not having names is a problem. –  Christian Lindig Jan 21 '12 at 11:35
    
@ChristianLindig I am not familiar with OSX pdf readers, but at a stage forms could only be saved with Acrobat Pro and enabled for other Readers only via the Acrobat Pro user. Try this tex.stackexchange.com/questions/7869/… to see if you can view it properly. –  Yiannis Lazarides Jan 21 '12 at 11:38
    
The document you linked to requires many packages that I am too reluctant to install just for this purpose. For now I am hoping that someone will take a look into the generated PDF to see how the problem manifests itself. –  Christian Lindig Jan 21 '12 at 12:23
2  
@ChristianLindig That's fine in the meantime you can open the pdf file with a TeX editor and post the code at about /Type /XObject /Subtype /Form /BBox [0 0 36.496 13.693] /FormType 1 it might help others to come with a better answer. –  Yiannis Lazarides Jan 21 '12 at 12:28
    
I'd post the PDF code but it includes binary streams. Is there a way to force PDFLaTeX to generate more readable output? Option -8bit is not enough. –  Christian Lindig Jan 21 '12 at 13:13
show 2 more comments

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.