How to prevent font resizing when filling out form fields

Q:

The issue we are seeing is the default behavior of the PDF viewer will resize a font to fill a widget. This causes font sizes to be inconsistent. In particular, the font size increases to fill the widget space.

Is there a way to set this behavior so that auto sizing does not happen?

A:

This behavior is actually controlled by the PDF file creator, and any text field with a font size of zero means that the content should be scaled to fit. PDFviewCtrl is just following the field settings.

We don’t currently expose any functions that will do this for you. Instead, you would need to modify, or pre-process the PDF, using PDFNet.

You may want to use our COSEdit tool that comes with the desktop version of PDFNet (just download a trial version). First look for the entry trailer/Root/Acroform/DA. This is an optional entry that sets the default font and text size for fields. The rest of the fields are under trailer/Root/Acroform/Fields, and they can have their own DA entries.

So, programmatically, you would need first call PDFDoc::GetAcroForm and then replace the DA entry, with a string like this “/Helv 12 Tf 0 1 0 rg” which will set the default field text to Helvetica 12 pt font, and red color.

Then, using the PDFDoc::GetFieldIterator, you would go through each Field entry, call Field::GetSDFObj and then delete the DA entry if present. Though, maybe you don’t for all fields, or just some? CosEdit can help you figure out which fields you want to affect with these changes.

See the follow pages for details on how to do all this.
https://groups.google.com/forum/?fromgroups#!searchin/pdfnet-sdk/field$20font$20size/pdfnet-sdk/n43OZqxaFfM/5N5dX6S0bdwJ
https://groups.google.com/forum/?fromgroups#!searchin/pdfnet-sdk/field$20font$20size/pdfnet-sdk/bNO73SNojEM/4lS6ZZVRMAoJ
http://www.pdftron.com/pdfnet/intro.html#low_level_api
http://www.pdftron.com/pdfnet/intro.html#forms
http://www.pdftron.com/pdfnet/mobile/iOSHTMLDoc/classes.html