Making fillable forms in LaTeX using TextField and CheckBox
You can change the height of a textfield with the height option or by redefining \DefaultHeightofText. But the minimal height of the field will always be the height of the surrounding box. In a tabular cell (which contains a \strut) this is the height of the cell. If you want to avoid this you can add an additional box:
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{array}
\usepackage{hyperref}
\usepackage{babel}
\begin{document}
%suppress the label:
\def\LayoutTextField#1#2{% label, field
#2%
}
\begin{Form}
\def\DefaultHeightofText{5pt}
\mbox{\strut\TextField[width=3cm]{namea}} \mbox{\TextField[width=3cm]{namea}}
\begin{tabular}{ll}
Name: & \mbox{\TextField[width=3cm]{namea}} \\%smaller
Name: & \TextField[width=3cm]{namea}
\end{tabular}
\end{Form}
\end{document}
- In general, the height of a
TextField
is controlled by the macro\DefaultHeightofText
; I can't tell you why it does not work in a table. I had this issue also once and I gave up on it. It works in regular text (see below). - You can change to color of text inside
TextField
withcolor
key. The color spec must be in RGB triple, in the range 0..1. There is also abordercolor
key. CheckBox
es andTextField
s take a mandatorylabel
argument. Thislabel
is used to make them unambiguous. If you want to leave this argument empty, use thename
key for a unique label.
Code:
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{array}
\usepackage{babel}
\usepackage{xcolor}
\usepackage{hyperref}
\begin{document}
\begin{Form}[action=http://your-web-server.com/path/receiveform.cgi]
\noindent \def\DefaultHeightofText{5pt}%
\begin{tabular}{@{}ll>{\centering\arraybackslash}p{0.6cm}ll}
Name: & \TextField[name=name, width=5cm, color=0.18 0.55 0.34, % seagreen
bordercolor=1 0 1, charsize=9pt, height=3pt]{}
& & Name: & Need TextField here \\
Client's Name: & \TextField[name=client, width=5cm]{}
& & Advisor Name: & \rule{5cm}{1pt}
\end{tabular}
\vspace*{0.3cm}
\noindent
Have you ? \hfill{} \CheckBox[height=0.01cm, width=0.4cm]{Yes}
\hfill{} \CheckBox[height=0.01cm, width=0.4cm]{No}
\noindent
\Submit{Submit}
\vspace{3ex}
\def\DefaultHeightofText{5pt}
\TextField{5pt}
\vspace{3ex}
\def\DefaultHeightofText{\baselineskip}
\TextField{baselineskip}
\end{Form}
\end{document}
Rather then tabular
environment you can use multicol
package to split your fields on two columns, in this case you can modify height of textfield as you like
More detail can be found in this answer
\documentclass[english]{article}
\usepackage[margin=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{array}
\usepackage{babel}
\usepackage{xcolor}
\usepackage{multicol}
\usepackage{hyperref}
\parindent0pt
\renewcommand*{\LayoutTextField}[2]{\makebox[7em][l]{#1: }%
\raisebox{\baselineskip}{\raisebox{-\height}{#2}}}
\begin{document}
\begin{Form}[action=http://your-web-server.com/path/receiveform.cgi]
\begin{multicols}{2}
\TextField[name=name, width=4cm, color=0.18 0.55 0.34, % seagreen
bordercolor=1 0 1, charsize=9pt]{Name} \vskip2ex
\TextField[name=client ,width=4cm]{Client's Name}
\columnbreak
\TextField[name=name2,width=4cm]{Name} \vskip2ex
Advisor Name: \rule{4cm}{1pt}
\end{multicols}
\vspace*{0.3cm}
\noindent
Have you ? \hfill{} \CheckBox[height=0.01cm, width=0.4cm]{Yes}
\hfill{} \CheckBox[height=0.01cm, width=0.4cm]{No}
\noindent
\Submit{Submit}
\end{Form}
\end{document}