# Typesetting fillable PDF forms with hyperref

I'm trying to create a fillable PDF form with hyperref and I want there to be a long line instead of a box for a text field. At the moment I'm using the following code:

\documentclass{scrartcl}

\usepackage{hyperref}
\usepackage{amsmath}

\renewcommand\LayoutTextField[2]{%
#2
}

\begin{document}
\begin{Form}
Name: \dotfill$\overset{\TextField[width=4cm,borderwidth=0pt]{\null}}{\rule{4cm}{.4pt}}$
\end{Form}
\end{document}


This works and achieves what I want but I was just wondering if there was a better way to do it? For some reason this solution seems inelegant to me.

You can set the borderstyle to underline. Or add some tikz and other code to the layout. In the second case set the colors to transparent. It is also often quite useful to move the field a bit down to get a better alignment with the label:

\documentclass[parskip=full-]{scrartcl}

\usepackage{hyperref}
\usepackage{tikz}
\usepackage{amsmath}

\begin{document}
\begin{Form}
\renewcommand\LayoutTextField[2]{%
#2}

Name: \TextField[width=4cm,borderstyle=U]{nameA}{\rule{4cm}{.4pt}}

\renewcommand\LayoutTextField[2]{%
\raisebox{-3.2pt}{\tikz[overlay]\draw[dashed](0,-0.2\dp\strutbox)--++(\csname Fld@width\endcsname,0pt);#2}}

Name: \TextField[width=4cm,bordercolor={},backgroundcolor={}]{nameB}{\rule{4cm}{.4pt}}

\renewcommand\LayoutTextField[2]{%

• Great! Thanks. I tried looking for a borderstyle option in the hyperref manual but couldn't find any. I love the simplicity of that solution. Also, I'm doing it the other way round from what you suggested. I added a raisebox to the label to align it with the text field better. – K G Oct 31 '17 at 14:37
• Ok borderstyle=U doesn't work. – K G Oct 31 '17 at 14:44
• I'm also wondering where the syntax for borderstyle=U is documented. I couldn't find anything in ctan.mirror.colo-serv.net/macros/latex/contrib/hyperref/doc/… – Fuhrmanator Aug 15 '18 at 16:45