Q: How do I make a PDF form field fit a table cell? I'd like to make a document with PDF forms in such a way that the text is justified. Obsiously, it would bean that all forms will have different width depending on the field label. The easiest way seems to be is to put the fields in a table.

*

*How do I prevent the fields from overlapping horizontally? Can fields fill the table column taking the label into account?

*How do I make sure that the fields do not blend vertically?

MWE:
\usepackage{hyperref}
\usepackage{tabularx}
\def\DefaultOptionsofText{print,borderwidth=0, backgroundcolor={0.9 0.9 0.9}}

\begin{document}
    \begin{tabular}{ | m{0.45\textwidth} | m{0.45\textwidth} | }
        \hrule
        \TextField[width=\linewidth]{Name}
        &
        \TextField[width=\linewidth]{Surname}
        \\
        \hrule
        \TextField[width=\linewidth]{Name}
        &
        \TextField[width=\linewidth]{Surname}
        \\
        \hrule
    \end{tabular}
\end{document}


A: You can leave the label empty and set the name (which should be different for every field anyway) with the name key. Then you are free to add the label in another column.
You can set the height of the textfield with the height key, but normally the result is better if you move it a bit down and increase the array stretch.
\documentclass[12pt]{book}
\usepackage{hyperref}
\def\DefaultOptionsofText{print,borderwidth=0, backgroundcolor={0.9 0.9 0.9}}
\usepackage{array}

\begin{document}
 \Form
    \renewcommand\arraystretch{1.3}
    \begin{tabular}{ | r  m{0.4\textwidth} | r  m{0.4\textwidth} | }
        \hline
       Name & \raisebox{-0.28\normalbaselineskip}{\TextField[name=name1,width=\linewidth]{}}
            &
       Surname & \raisebox{-0.28\normalbaselineskip}{\TextField[name=surname1,width=\linewidth]{}}
        \\
        \hline
       Name &  \raisebox{-0.28\normalbaselineskip}{\TextField[name=name2,width=\linewidth]{}}
        &
       Surname &  \raisebox{-0.28\normalbaselineskip}{\TextField[name=surname2,width=\linewidth]{}}
        \\
        \hline
    \end{tabular}
\end{document}


