![テキストフィールド名を指定せずに PDF フォームに一意のテキストフィールドを作成する方法](https://rvso.com/image/420745/%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%E3%83%95%E3%82%A3%E3%83%BC%E3%83%AB%E3%83%89%E5%90%8D%E3%82%92%E6%8C%87%E5%AE%9A%E3%81%9B%E3%81%9A%E3%81%AB%20PDF%20%E3%83%95%E3%82%A9%E3%83%BC%E3%83%A0%E3%81%AB%E4%B8%80%E6%84%8F%E3%81%AE%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%E3%83%95%E3%82%A3%E3%83%BC%E3%83%AB%E3%83%89%E3%82%92%E4%BD%9C%E6%88%90%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95.png)
この質問はテキストフィールドで一意の名前を生成する
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}