# hyperref forms cause PDF changes when viewer opens it

After working with hyperref forms I have noticed that employing some format options produces a strange behaviour when opening the output PDF (in PDF XChange viewer/editor at least): the program shows an asterisk warning about changes made in the file, asking if you want to save them when closing it. What is the reason behind and how to solve this problem? I attach a MWE:

\documentclass{book}
\usepackage{hyperref}
%\usepackage{xcolor}%

\begin{document}
\begin{Form}
\TextField[%width=4cm, height=.25cm, %
name = field,
format = {%
var f = this.getField('field');%
%       f.textFont = ['Calibri Light'];%< -- -- -- PROBLEM
%        f.strokeColor = ['T'];%        < -- -- -- PROBLEM
%        f.fillColor = ['T'];%          < -- -- -- PROBLEM
%       f.alignment = ['center']%       < -- -- -- PROBLEM
},%
charsize = 10.5pt,%
%   color= blue,
%    value=test
]
{}%
\end{Form}
\end{document}


hyperref forces NeedAppearances to true when form fields are used (that's an internal pdf setting). This means that when loading the pdf the reader changes the pdf to show the borders around the fields, and when quitting it asks you if you want to save the changes.

You can set the value to false with

 \begin{Form}[NeedAppearances=false]


You then should perhaps changes the settings in the reader (Edit->Forms) so that they show a background:

In the long run hyperref should/will add the borders through an dictionaries of the form fields (/NeedAppearances is deprecated in pdf 2.0), but this will take some time to implement.

• No. It is not the Form, but only certain options. Indeed, this solution does not work for me. On the other hand, Xchange viewer is not showing other colors than 'T', but just warning about changes. – Andrestand Jun 10 '19 at 7:32
• Well with adobe it is already the form (and NeedAppearances=false). With pdf xchange it seems only to appear if one activate one of your options in the example (and it would have been better if you hadn't commented them if they are part of the problem). I don't think that there is anything that can be done by hyperref, that's clearly a decision of the pdf viewer. – Ulrike Fischer Jun 11 '19 at 13:29
• @KJO form is required when the information that must fill the gap is not available before producing the PDF. So other person is going to fill it, and it needs to emulate the sffamily from kpfonts. That font option is the only I found. – Andrestand Jun 11 '19 at 17:00