Custom Fonts in Form Fields
When styling interactive form fields, the SetFont() method cannot apply a custom font. There is no error; the font request is simply ignored, leaving the field in its default appearance.
Custom font styling is not yet supported through SetFont(). Until that lands in a future release, you can drive the font, size, and color directly through the field's DefaultAppearance property, which takes a string of raw PDF drawing instructions.
Solution
1. Set the appearance string by hand
Load the document, grab the field, and assign a DefaultAppearance string that describes the font, size, and color:
var pdf = PdfDocument.FromFile("FilledForm.pdf");
TextFormField field = pdf.Form[0] as TextFormField;
// Manually define the appearance string:
// Format: /{FontName}-{Weight} {FontSize} Tf {R} {G} {B} rg
field.DefaultAppearance = "/AdobeThai-Bold 15 Tf 0.898 0.133 0.215 rg";
field.Value = "This is size 15";
pdf.SaveAs("customformfieldvalue15.pdf");
var pdf = PdfDocument.FromFile("FilledForm.pdf");
TextFormField field = pdf.Form[0] as TextFormField;
// Manually define the appearance string:
// Format: /{FontName}-{Weight} {FontSize} Tf {R} {G} {B} rg
field.DefaultAppearance = "/AdobeThai-Bold 15 Tf 0.898 0.133 0.215 rg";
field.Value = "This is size 15";
pdf.SaveAs("customformfieldvalue15.pdf");
Imports System
Dim pdf = PdfDocument.FromFile("FilledForm.pdf")
Dim field As TextFormField = TryCast(pdf.Form(0), TextFormField)
' Manually define the appearance string:
' Format: /{FontName}-{Weight} {FontSize} Tf {R} {G} {B} rg
field.DefaultAppearance = "/AdobeThai-Bold 15 Tf 0.898 0.133 0.215 rg"
field.Value = "This is size 15"
pdf.SaveAs("customformfieldvalue15.pdf")
The string is parsed as PDF text operators, so the font you name must be installed on the machine rendering the document.
2. Read the appearance string
Each token in the string maps to one part of the field's styling:
/AdobeThai-Bold: the font name and weight. This font must be installed on the system.15 Tf: the font size, here 15 pt.0.898 0.133 0.215 rg: the RGB color, in this case a reddish shade.
This gives you full control over the font and color of form field text until SetFont() support arrives in a later IronPDF release.

