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")
$vbLabelText   $csharpLabel

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.

WarningThe named font must be installed on the system rendering the PDF. If it is missing, the styling will not apply as written.

This gives you full control over the font and color of form field text until SetFont() support arrives in a later IronPDF release.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...

Read More
Ready to Get Started?
Nuget Downloads 19,680,294 | Version: 2026.7 just released
Still Scrolling Icon

Still Scrolling?

Want proof fast? PM > Install-Package IronPdf
run a sample watch your HTML become a PDF.