0

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?

enter image description here

\documentclass[fontsize=14pt]{scrreprt}
\usepackage{xcolor}
\usepackage[]{hyperref}

% Gobal Styles
\def\Default{
print, bordercolor=red,backgroundcolor=lightgray,borderstyle={U},
}
\xdef\DefaultOptionsofText{\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}
1
\documentclass[fontsize=14pt]{scrreprt}
\usepackage{xcolor}
\usepackage[]{hyperref}

% Global Styles
\def\DefaultOptionsofText{
 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}

enter image description here

  • @ Ulrike Fischer You are a Turbo Woman! :() – cis Jan 7 at 18:19
  • But as I recall @UlrikeFischer this is not going to work reliably beyond the compiler's own computer. Unless the full fonts are embedded (which is hard to achieve?) or the viewer has the font installed locally it will not work and will be worse than using an always-available system font (which will be unpredictable). – Aubrey Blumsohn Jan 8 at 10:57
  • @AubreyBlumsohn Ok, I think, I understand. I thought, "Courier" is usually available in Win or Linux systems. What could a "always-available system font" be? BTW: Are there any fonts that AdobeReader ships with by default? AdobeReader is, to my knowledge, a mandatory prerequisite for this type of form. – cis Jan 8 at 15:21
  • Yes you may be relatively (not completely) safe with a few fonts (Palatino Garamond, Bookman, courier..). Many pdf readers other than AdobeReader can open/process forms. But my point was more general - you will not be able to select any random font and think that you will have a system independent product (in contrast to fonts outside the form which can be embedded regardless of whether they exist on the system). Adobe Reader does contain some fonts which do not need to be embedded (courier being the only fixed point one afaik). – Aubrey Blumsohn Jan 8 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.