テキストフィールド名を指定せずに PDF フォームに一意のテキストフィールドを作成する方法

テキストフィールド名を指定せずに PDF フォームに一意のテキストフィールドを作成する方法

この質問はテキストフィールドで一意の名前を生成する

hyperref私はPDF フォームの生成に使用しているため、上記の質問で提供されているソリューションは使用できません。

私のドキュメントには多くのテーブルがあり、それらに PDF フォームを作成したいと考えています。テキスト フィールドの名前は重要ではなく、ユーザーが入力できるだけで十分です。

問題は、ユーザーが PDF ビュー内のテキストフィールドの 1 つに入力しようとすると、他のフィールドも入力されてしまうことです。

\TextField{}の代わりにを使用すると\TextField{\ }、Acrobat Reader で PDF ファイルを開いたときにテキストフィールドが表示されません。

\documentclass{article}
\usepackage{hyperref}

\begin{document}

\begin{Form}
\begin{tabular}{llll}
 A &  B  & C &  D  \\
\TextField{\ }  & \TextField{\ } & \TextField{\ } & \TextField{\ }\\
\TextField{\ }  & \TextField{\ } & \TextField{\ } & \TextField{\ } \\
\TextField{\ }  & \TextField{\ } & \TextField{\ } & \TextField{\ } 
\end{tabular}
\end{Form}

\end{document}

答え1

テキスト フィールドには一意の名前が必要ですが、たとえばカウンターと新しいコマンドを使用して生成できます。

\documentclass{article}
\usepackage{hyperref}
\newcounter{textfield}
\newcommand\AutoTextField{\stepcounter{textfield}\TextField[width=2cm,name=autotextfield\thetextfield]{}}
\begin{document}

\begin{Form}
\begin{tabular}{llll}
 A &  B  & C &  D  \\
\AutoTextField  & \AutoTextField & \AutoTextField & \AutoTextField\\
\AutoTextField  & \AutoTextField & \AutoTextField & \AutoTextField \\
\AutoTextField  & \AutoTextField & \AutoTextField & \AutoTextField
\end{tabular}
\end{Form}

\end{document}

ここに画像の説明を入力してください

関連情報