# Underlined text field in a fillable form

Is there a way to make an underlined text field in a fillable form?

I am using the hyperref package to make a fillable form but I would also like to give the option of printing out the form and filling it by hand. For the later, a line is helpful to serve as guide for the pen.

This

\TextField[name=firstname,width=5cm,charsize=11pt]{First Name}


gives an empty box and I cannot find an easy way to underline this box.

-
– Claudio Fiandrino Mar 9 '13 at 13:01

The printing of the field is controlled by \MakeTextField whose default definition is equivalent to

\newcommand{MakeTextField}[2]{\vbox to #2{\hbox to #1{\hfill}\vfill}}


Replacing the inside \hfill with an \hrulefill produces a horizontal line, but because of the placing of the \vfill these will be at the top of the box. Moving the placement of \vfill gives a line at the bottom via

\renewcommand{\MakeTextField}[2]{{\vbox to #2{\vfill\hbox to #1{\hrulefill}}}}


You will probably want to adjust the colour to black (rather than the gray I get as default):

\documentclass{article}

\usepackage{hyperref,xcolor}

\renewcommand{\MakeTextField}[2]{{\vbox to #2{\vfill\hbox to #1{\hrulefill}}}}

\begin{document}
\begin{Form}
\TextField[name=firstname,width=5cm,charsize=11pt,color=black]{First Name}
\end{Form}
\end{document}

-
Thanks, that solved it. – latexform Mar 10 '13 at 7:40
Strangely, this doesn't seem to do anything in pdflatex, though it does give lines in xelatex. You wouldn't know why that is, would you? – leftaroundabout Apr 1 '15 at 13:43
The above sample is pdflatex, so I guess it is an April fool. – Andrew Swann Apr 8 '15 at 12:23