# How to create a document containing forms?

Is it easy to make a PDF document containing forms in LaTeX? I tried to use TextFields but a friend of mine said that it won't work on every operating system PDF readers?

• Would acrotex.net help? – pluton Jul 6 '14 at 19:35
• I haven't done this myself but the hyperref package seems to have everything that you would need. – Andrew Jul 6 '14 at 21:14
• Please have a look for example on this recent question (although it does not work in that case for some unknown reason on Windows): tex.stackexchange.com/questions/187767/… – user31729 Jul 6 '14 at 21:39
• @ChristianHupfer Thanks but in my case the document should work on Linux, Windows and Mac. – novice Jul 6 '14 at 21:49
• @novice: Well, the form works nevertheless, but on Windows, due to some reasons, the checkboxes are not checked initally. If you do not need such an prechecked box, there is no problem at all – user31729 Jul 6 '14 at 21:52

In the future, please note that all questions should include an MWE. You are likely to get more useful help if you provide one, as well as increasing the number of people willing to provide that help.

In this case, I provide a simple example of a form which includes multiline text fields and choice menus. Some of the former have default text and others do not. The latter use drop-down boxes allowing the user to choose one of three possibilities for each item. A uniform default is set for each set of items.

Note that the form will not look precisely the same in all PDF viewers and that some PDF viewers will not support form fields at all.

Note, too, that Adobe Reader will not allow users to save the filled form. Plenty of other viewers (e.g. Okular) will do, however.

# A First Attempt

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\pagestyle{empty}
\begin{Form}
\centering
\TextField[charsize={10pt},multiline=true,height={60mm},width={100mm},name={textfield1},bordercolor={1 1 1}]{First, a simple text field with no default text:\\
}
\vskip 5pt

\begin{minipage}[b]{.35\textwidth}

\begin{itemize}
\end{itemize}
}

\end{minipage}
\hfill
\begin{minipage}[b]{.55\textwidth}
Note that \verb|name|s must be unique:

\begin{itemize}
\end{itemize}
\TextField[charsize={10pt},multiline=true,height={10mm},width={.9\linewidth},name={morefeats},bordercolor={0.2 0.2 0.7},default={possession of additional features}]{\mbox{}
}

\end{minipage}
\end{Form}
\end{document}


Here is the form filled out in Okular with form fields shown:

# Correcting the Code

The above is pretty good except that our choice menus do not show the first (default) item in the list when form fields are not active (or, apparently, when you copy the contents as a png to post here). So it would be better to have the first item be a blank/neutral setting with the first of the three possibilities given as the second item in the menu:

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\pagestyle{empty}
\begin{Form}
\centering
\TextField[charsize={10pt},multiline=true,height={60mm},width={100mm},name={textfield1},bordercolor={1 1 1}]{First, a simple text field with no default text:\\
}
\vskip 5pt

\begin{minipage}[b]{.35\textwidth}

\begin{itemize}
\end{itemize}
}

\end{minipage}
\hfill
\begin{minipage}[b]{.55\textwidth}
Note that \verb|name|s must be unique:

\begin{itemize}