Creating fillable PDFs
The hyperref
package provides a method to create PDF forms. The way I understand it, the form is either to be printed or to be transmitted to a webserver like a HTML form.
Here a small example:
\documentclass{article}
\usepackage{hyperref}
\begin{document}
\begin{Form}[action={http://your-web-server.com/path/receiveform.cgi}]
\begin{tabular}{l}
\TextField{Name} \\\\
\CheckBox[width=1em]{Check} \\\\
\Submit{Submit}\\
\end{tabular}
\end{Form}
\end{document}
Gives:
Here is some code that I use to create forms that can be either printed and filled out with a pen or filled out electronically in a PDF viewer. When printed, the form provides a line for each form field. Like Martin Scharrer's solution I'm using the hyperref
package. The tricky bit was to define an input field of a given length (here textwidth
minus 4 cm). It required to override the \LayoutTextField
hook.
\documentclass[a4paper,11pt]{article}
\usepackage[latin1]{inputenc}
\usepackage[pdftex]{hyperref}
\newdimen\longline
\longline=\textwidth\advance\longline-4cm
\def\LayoutTextField#1#2{#2} % override default in hyperref
\def\lbl#1{\hbox to 4cm{#1\dotfill\strut}}%
\def\labelline#1#2{\lbl{#1}\vbox{\hbox{\TextField[name=#1,width=#2]{\null}}\kern2pt\hrule}}
\def\q#1{\hbox to \hsize{\labelline{#1}{\longline}}\vskip1.4ex}
\begin{document}
\begin{Form}
\q{First Name}
\q{Last Name}
\q{Email}
\end{Form}
\end{document}
In a PDF viewer each line becomes a form field.
I've used the eforms
package, which is used by DANTE for their membership form (which of course I can't now locate in .tex
format!). You'll probably have to download and unpack eforms
from CTAN yourself, as it's not in TeX Live (unpack eforms
, insdljs
and taborder
, all in the eforms
bundle). A short example from a registration form I've done:
\documentclass{article}
\usepackage[pdftex]{eforms}
% From DANTE's registration form!
\newcounter{infoLineNum}
\setcounter{infoLineNum}{0}
\newcommand{\infoInput}[2][4in]{%
\stepcounter{infoLineNum}%
\makebox[0pt][l]{%
\kern 4 pt
\raisebox{.75ex}
{\textField[\W0\BC{}\BG{}\TU{#2}]{name\theinfoLineNum}{#1}{12bp}}%
}
\dotfill
}
\begin{document}
\begin{tabular}{lp{4in}}
Title & \infoInput{Title}\\[6pt]
First name & \infoInput{Firstname}\\[6pt]
Last name & \infoInput{Surname}\\[6pt]
E-mail address & \infoInput{Email}\\[6pt]
Dietary requirements & \infoInput{Dietary}\\[6pt]
\end{tabular}
\begin{tabular}{ll}
Student (\pounds60)
& \raisebox{.75ex}{\radioButton{RegType}{10bp}{10bp}{Student}}
\\[6pt]
Academic/post-doc (\pounds120)
& \raisebox{.75ex}{\radioButton{RegType}{10bp}{10bp}{Academic}}
\\[6pt]
Industrial (\pounds180)
& \raisebox{.75ex}{\radioButton{RegType}{10bp}{10bp}{Industrial}}
\\[6pt]
\end{tabular}
\end{document}
This gives 'type in' boxes for the text areas and 'tick' boxes for the choices.
I'm not sure what happens about saving form data: according to Adobe Reader it can't be saved in this form. I've never actually seen a PDF form that can have the data saved, so whether even Acrobat can do this I do not know.