Skip to content
English
  • There are no suggestions because the search field is empty.

IronPDF: How to Apply Custom Fonts for Non-ASCII Form Field Values

Overview

IronPDF automatically embeds a Tahoma/Arial fallback font whenever a form field's Value is set to a non-ASCII string, which can override the font a template actually needs. As of IronPDF 2026.6.1, SetFormFont, SetFormFontFromFile, and DisableFormFontFallback give direct control over this behavior.


Prerequisites

  • IronPDF 2026.6.1 or later (.NET). Equivalent functionality ships in IronPDF Python 2026.6.0.1+ and IronPDF Java 2026.6.1+, but under each language's own naming convention (e.g. Java's FormManager.setFormFont/setFormFontFromFile/disableFormFontFallback, camelCase) — not verified here to the same standard as the C# signatures below.
  • A TrueType/OpenType (.ttf/.otf) font file if you want to embed a specific font rather than just suppressing the fallback.

Version Metadata

  • Minimum Version: 2026.6.1
  • Superseded-in Version: N/A

Solution

Before IronPDF 2026.6.1 (manual workaround)

SetDefaultFont() on a form field does not control the Tahoma/Arial auto-fallback for non-ASCII text. The only way to override the appearance was to construct the field's DefaultAppearance string by hand:

field.DefaultAppearance = "/Helvetica-Bold 12 Tf 0 0 0 rg";

The format is /{FontName}-{Weight} {FontSize} Tf {R} {G} {B} rg. The named font must already be registered in the document's AcroForm resource dictionary, and the values are raw PDF text operators — there is no validation.

IronPDF 2026.6.1 and later (recommended)

Three document-wide methods on PdfDocument replace the workaround. Set the font before filling any field that needs it.

Option A — Embed a specific font from bytes: SetFormFont

 var pdf = PdfDocument.FromFile("template.pdf");
pdf.SetFormFont("Poppins-Regular", File.ReadAllBytes("Poppins-Regular.ttf"));
pdf.Form.FindFormField("bookingNumber").Value = "FONT TEST: € ş ğ";
pdf.SaveAs("filled.pdf");

Option B — Embed a specific font from a file path: SetFormFontFromFile

 var pdf = PdfDocument.FromFile("template.pdf");
pdf.SetFormFontFromFile("Poppins-Regular.ttf");
pdf.Form.FindFormField("bookingNumber").Value = "FONT TEST: € ş";
pdf.SaveAs("filled.pdf");

Option C — Suppress the fallback with zero file-size cost: DisableFormFontFallback

 var pdf = PdfDocument.FromFile("template.pdf");
pdf.DisableFormFontFallback();

// do not auto-embed Tahoma/Arial
pdf.Form.FindFormField("bookingNumber").Value = "AS2323445";
pdf.SaveAs("filled.pdf");

Use Option C when the template's existing font references (plus the PDF viewer's own font substitution) already render the values correctly — it adds nothing to the document.

All three examples assume a field named "bookingNumber" exists in template.pdf. FindFormField returns null if the name doesn't match any field in your own template — check for null before setting .Value, or you'll get a NullReferenceException rather than a font problem.

Notes and Limitations

  • All three methods are document-wide, not per field. If different fields need different fonts, call SetFormFont once per font variant.
  • The auto-fallback only triggers when a field's Value is set to a non-ASCII string. Other field updates (renaming, ReadOnly) are unaffected regardless of which option you use.
  • fontName allows letters, digits, -, _, ., +. A 6-letter PDF subset prefix (e.g. AAAAAA+Poppins-Regular) is accepted and stripped automatically to the canonical name.
  • SetFormFont writes into the AcroForm /DR /Font dictionary under the given fontName. If the template already used that exact name for a different font, it gets replaced — use a non-colliding name if you need to preserve the original mapping.
  • forceEmbed: true always adds a fresh font copy on every call, growing the file each time. Leave it false unless you know the existing embed is stale.
  • SetFormFont throws ArgumentException for an invalid fontName or fontData. SetFormFontFromFile also throws FileNotFoundException if the path doesn't exist.
  • The unrelated, pre-existing per-field method IFormField.SetDefaultFont(fontName, fontSize, fontColor) still exists and is unchanged — it sets a field's appearance using a font that must already be installed on the rendering machine, and does not affect the non-ASCII auto-fallback described here.

References