TeX - LaTeX Asked on February 16, 2021
I would like to have typewriter-font into my pdf-form.
So I find out the mechanism
TextField[width=5cm, name=NAME,value=Font manually changed,
format = { var f = this.getField('NAME'); f.textFont = 'Courier'; },
]{B: }
depending on the name
of the textfield.
I can do this smarter using a corresponding command, but I ask myself:
Is there a possibility to set the font globally for all textfields?
documentclass[fontsize=14pt]{scrreprt}
usepackage{xcolor}
usepackage[]{hyperref}
% Gobal Styles
defDefault{
print, bordercolor=red,backgroundcolor=lightgray,borderstyle={U},
}
xdefDefaultOptionsofText{Default}
begin{document}
begin{Form}
TextField[width=5cm, name=a,value=Default Font]{A: }
TextField[width=5cm, name=b,value=Font manually changed,
format = { var f = this.getField('b'); f.textFont = 'Courier'; },
]{B: }
Let's do this with a newcommand:
% TEXTFIELD[<opt. Arg.>]{<name>}{<title>}
newcommand{TEXTFIELD}[3][]{%%
TextField[width=5cm,
name = #2,
format = { var f = this.getField('#2'); f.textFont = 'Courier'; },
#1,
]{#3}
}%%
bigskip
TEXTFIELD[value={Font changed}]{C}{C:}
TEXTFIELD[value={Font changed too}]{D}{D:}
end{Form}
end{document}
documentclass[fontsize=14pt]{scrreprt}
usepackage{xcolor}
usepackage[]{hyperref}
% Global Styles
defDefaultOptionsofText{
print, bordercolor=red,backgroundcolor=lightgray,borderstyle={U},
format = {var me = event.target.name;
var f = this.getField(me);
f.textFont = 'Courier'; }}
begin{document}
begin{Form}
TextField[width=5cm, name=a,value=Default Font]{A: }
TextField[width=5cm, name=b,value=Font manually changed,
]{B: }
end{Form}
end{document}
Correct answer by Ulrike Fischer on February 16, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP