如何升高或降低 pdf 表單中的文字欄位?

如何升高或降低 pdf 表單中的文字欄位?

hyperref我在生成的文字欄位與其下方相應的直線之間遇到了不對齊問題。附圖說明了這個問題。

文字欄位與下面的行未對齊

目標很明確。我想降低文字字段,使每個文字字段位於相應直線的正上方。我的程式碼如下:

\documentclass{article}

\usepackage{hyperref}

\begin{document}

\begin{flushleft}
    \begin{Form}
\renewcommand{\baselinestretch}{1.0}
\fontsize{12}{24}\selectfont
\hspace*{2cm} \TextField[name=First and Last Name, width=8cm, borderwidth=1]{}\\
\hspace*{2cm} \rule[-2.5ex]{11.4cm}{0.5pt} \\
\hspace*{2cm} advisor, \hspace{2cm} Date\\
\hspace*{2cm} \TextField[name=First and Last Name, width=8cm, borderwidth=1]{}\\
\hspace*{2cm} \rule[-2.5ex]{11.4cm}{0.5pt} \\
\hspace*{2cm} memberA \\
\hspace*{2cm} \TextField[name=First and Last Name, width=8cm, borderwidth=1]{}\\
\hspace*{2cm} \rule[-2.5ex]{11.4cm}{0.5pt} \\
\hspace*{2cm} memberB \\
\hspace*{2cm} \TextField[name=First and Last Name, width=8cm, borderwidth=1]{}\\
\hspace*{2cm} \rule[-2.5ex]{11.4cm}{0.5pt} \\
\hspace*{2cm} memberC \\
\hspace*{2cm} \TextField[name=First and Last Name, width=8cm, borderwidth=1]{}\\
\hspace*{2cm} \rule[-2.5ex]{11.4cm}{0.5pt} \\
\hspace*{2cm} memberD \\
    \end{Form}
\end{flushleft}


\end{document}

總是可以選擇提高線條,但我也必須提高簽名標題(例如advisormemberA)。如果可能的話,我更願意降低文字字段,因為如有必要,我始終可以使用 Acrobat 手動建立它們。

任何幫助將不勝感激。

答案1

我會使用 atabular以及booktabs

\documentclass[12pt]{article}
\usepackage{booktabs}
\usepackage{hyperref}

\begin{document}
\begin{Form}
\begin{tabular}{@{}p{11.5cm}@{}}
\TextField[name=First and Last Name, width=8cm, borderwidth=1]{}\\\midrule[0.5pt]
advisor, \hspace{2cm} Date\\[2.5ex]
\TextField[name=First and Last Name, width=8cm, borderwidth=1]{}\\\midrule[0.5pt]
memberA\\[2.5ex]
\TextField[name=First and Last Name, width=8cm, borderwidth=1]{}\\\midrule[0.5pt]
 memberB\\[2.5ex]
\TextField[name=First and Last Name, width=8cm, borderwidth=1]{}\\\midrule[0.5pt]
memberC\\[2.5ex]
\TextField[name=First and Last Name, width=8cm, borderwidth=1]{}\\\midrule[0.5pt]
memberD
\end{tabular}
    \end{Form}


\end{document}

在此輸入影像描述

答案2

上面的答案是正確的。出於完整性考慮,我想添加我自己失敗嘗試的結果,以說明問題的不同方面。

如果我使用raisebox,我的程式碼會變成這樣:

\documentclass{article}

\usepackage{hyperref}

\begin{document}

\begin{flushleft}
    \begin{Form}
\renewcommand{\baselinestretch}{1.0}
\fontsize{12}{24}\selectfont
\raisebox{-1.0 cm}[2cm]{\TextField[name=First and Last Name, width=8cm, borderwidth=1, charsize=0pt]{} \TextField[name=Date, width=3.7cm, borderwidth=1, charsize=0pt]{}}\\
\rule[-2.5ex]{11.4cm}{0.5pt} \\
advisor, \hspace{7.3cm} Date\\
\hspace*{2cm} \raisebox{-1.0 cm}[2cm]{\TextField[name=First and Last Name, width=8cm, borderwidth=1]{}}\\
\hspace*{2cm} \rule[-2.5ex]{11.4cm}{0.5pt} \\
\hspace*{2cm} memberA \\
\hspace*{2cm} \raisebox{-3.0 cm}{\TextField[name=First and Last Name, width=8cm, borderwidth=1]{}}\\
\hspace*{2cm} \rule[-2.5ex]{11.4cm}{0.5pt} \\
\hspace*{2cm} memberB \\
\hspace*{2cm} \raisebox{-1.0 cm}{\TextField[name=First and Last Name, width=8cm, borderwidth=1]{}}\\
\hspace*{2cm} \rule[-2.5ex]{11.4cm}{0.5pt} \\
\hspace*{2cm} memberC \\
\hspace*{2cm} \raisebox{-1.0 cm}{\TextField[name=First and Last Name, width=8cm, borderwidth=1]{}}\\
\hspace*{2cm} \rule[-2.5ex]{11.4cm}{0.5pt} \\
\hspace*{2cm} memberD \\
    \end{Form}
\end{flushleft}


\end{document}

結果如圖所示。正如您所看到的,嘗試降低文字欄位確實raisebox成功了,直到達到臨界點。在此臨界點之後,不是單獨降低文字字段,而是降低整個「群組」(由文字字段、行和簽名標題組成)。

<code>Raisebox</code> 在一定程度上可以發揮作用

我的第二個觀察涉及上面提到的解決方案,booktabs它確實有效。如果我稍微改變一下程式碼,你會發現問題本質上是由命令引起的rule

    \documentclass[12pt]{article}
\usepackage{booktabs}
\usepackage{hyperref}

\begin{document}
\begin{Form}
\begin{tabular}{@{}p{11.5cm}@{}}
\TextField[name=First and Last Name, width=8cm, borderwidth=1]{}\\\rule[-2.5ex]{11.4cm}{0.5pt} 
advisor, \hspace{2cm} Date\\[2.5ex]
\TextField[name=First and Last Name, width=8cm, borderwidth=1]{}\\\midrule[0.5pt]
memberA\\[2.5ex]
\TextField[name=First and Last Name, width=8cm, borderwidth=1]{}\\\midrule[0.5pt]
memberB\\[2.5ex]
\TextField[name=First and Last Name, width=8cm, borderwidth=1]{}\\\midrule[0.5pt]
memberC\\[2.5ex]
\TextField[name=First and Last Name, width=8cm, borderwidth=1]{}\\\midrule[0.5pt]
memberD
\end{tabular}
\end{Form}


\end{document}

<code>rule引起的問題示範</code>

相關內容