TransWikia.com

How to create a fillable PDF file with many identical-looking but distinct boxes

TeX - LaTeX Asked by Maesumi on January 30, 2021

I want to make a document with dozens of identical looking boxes (as in first name, last name) that will be filled with different text.

If I copy/paste my code to generate the boxes then the resulting PDF will have the property that once a box is typed-in the other boxes will fill with the same entry.

Is there a quick/smart way of doing this task?

 documentclass{paper}
 usepackage{hyperref}
 begin{document}
 begin{Form}[action=mailto:[email protected]?subject={The form},method=post]
 TextField[width=5cm, height=0.6cm]{Type Last Name} 
 vskip .1in
 TextField[width=5cm, height=0.6cm]{Type First Name}
 vskip .1in
 TextField[width=5cm, height=0.6cm]{Type Last Name} 
 vskip .1in
 TextField[width=5cm, height=0.6cm]{Type First Name}
 vskip .1in
 end{Form}
 end{document}

One Answer

As Ulrike said in the comments all you need is a counter and then use the counter in the name key of each text box:

documentclass{paper}
usepackage{hyperref}
newcounter{textboxid}
newcommand{instextboxes}{%
  stepcounter{textboxid}%
  TextField[name=TextBoxthetextboxid, width=5cm, height=0.6cm]{Type Last Name}%
  vspace{0.1in}%
  par
  stepcounter{textboxid}%
  TextField[name=TextBoxthetextboxid, width=5cm, height=0.6cm]{Type First Name}%
  vspace{0.1in}%
  par}
begin{document}
begin{Form}[action=mailto:[email protected]?subject={The form},method=post]
  instextboxes
  instextboxes
  instextboxes
end{Form}
end{document}

Answered by David Purton on January 30, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP