How to Manage Fonts in HTML-to-PDF Conversion

How to Manage Fonts in PDFs with C#

IronPDF enables comprehensive font management in C# including finding, adding, embedding, unembedding, and replacing fonts in PDF documents to ensure consistent text display across all platforms.

A font is a set of characters, symbols, and glyphs with a consistent style and design. It represents a specific typeface, size, weight, and style (such as regular, bold, italic, etc.) of text. Fonts are used in typography to display text in a visually appealing and coherent manner.

IronPDF provides a convenient way to manage fonts, offering functionalities such as finding fonts, getting fonts, embedding fonts, unembedding fonts, and replacing fonts. Whether you're creating new PDFs or editing existing documents, proper font management ensures your PDFs display correctly across all platforms and devices.

Quickstart: Manage and Embed Fonts in Your PDF

Get started with IronPDF to streamline font management in your PDF documents. This guide shows how to embed fonts in PDFs for visual consistency across platforms. With just a few lines of code, you can enhance document appearance and maintain compatibility.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronPDF with NuGet Package Manager

    PM > Install-Package IronPdf

  2. Copy and run this code snippet.

    var pdf = PdfDocument.FromHtml("<p style='font-family:MyCustomFont;'>Hello world!</p>");
    pdf.Fonts.Add("MyCustomFont", File.ReadAllBytes("MyCustomFont.ttf"))
      .Embed()
      .SaveAs("withCustomFont.pdf");
  3. Deploy to test on your live environment

    Start using IronPDF in your project today with a free trial
    arrow pointer

How Do I Find and Retrieve Fonts in a PDF?

How do I retrieve all fonts from a PDF?

Accessing the Fonts property returns the PdfFontCollection object containing all document fonts. The Fonts property can be accessed directly by iterating over the PdfFontCollection object. This is particularly useful when working with PDF forms or analyzing document structure.

:path=/static-assets/pdf/content-code-examples/how-to/manage-font-retrieve-font.cs
using IronPdf;
using IronPdf.Fonts;
using System.Collections.Generic;

// Import PDF
PdfDocument pdf = PdfDocument.FromFile("sample.pdf");

// Retreive font
PdfFontCollection fonts = pdf.Fonts;
$vbLabelText   $csharpLabel

How do I find a specific font by name?

Finding specific fonts is straightforward with IronPDF. Using the PdfFontCollection object, specify the font name to access font objects and inspect properties. This functionality is essential when you need to replace text in PDF documents while maintaining font consistency.

:path=/static-assets/pdf/content-code-examples/how-to/manage-font-find-font.cs
using IronPdf;
using IronPdf.Fonts;
using System.Collections.Generic;
using System.Linq;

// Import PDF
PdfDocument pdf = PdfDocument.FromFile("sample.pdf");

// Find font
PdfFont font = pdf.Fonts["SpecialFontName"];
$vbLabelText   $csharpLabel

How Do I Add Fonts to a PDF?

Use the Add method to add standard fonts or font files as byte data. The method accepting font names only accepts one of the 14 standard fonts. Adding standard fonts doesn't embed them since they're guaranteed to be available on operating systems. When converting HTML to PDF, IronPDF automatically handles web fonts from your HTML.

:path=/static-assets/pdf/content-code-examples/how-to/manage-font-add-font.cs
using IronPdf;
using IronPdf.Fonts;

// Import PDF
PdfDocument pdf = PdfDocument.FromFile("sample.pdf");

// Add font
pdf.Fonts.Add("Helvetica");
$vbLabelText   $csharpLabel

For advanced font management including web fonts and icon fonts, IronPDF provides comprehensive support for modern typography needs.

Why Should I Embed Fonts in PDFs?

Embedding fonts includes the font's byte stream data in the PDF document. This ensures proper display without requiring font installation on viewing systems. While this increases file size, it guarantees visual consistency. This is crucial when creating PDF/A compliant documents or ensuring document portability.

:path=/static-assets/pdf/content-code-examples/how-to/manage-font-embed-font.cs
using IronPdf;
using System.Linq;

// Import PDF
PdfDocument pdf = PdfDocument.FromFile("sample.pdf");

// Add the font
byte[] fontData = System.IO.File.ReadAllBytes("dir/to/font.ttf");

// Embed the font
pdf.Fonts.Last().Embed(fontData);
$vbLabelText   $csharpLabel

Font embedding is particularly important for international languages and UTF-8 support to ensure characters display correctly across all systems.

When Should I Unembed Fonts from PDFs?

Unembedding removes embedded font byte stream data from PDFs to reduce file size. Use the Unembed method to achieve this. This technique works well with PDF compression strategies to minimize file sizes.

:path=/static-assets/pdf/content-code-examples/how-to/manage-font-unembed-font.cs
using IronPdf;
using IronPdf.Fonts;

// Import PDF
PdfDocument pdf = PdfDocument.FromFile("sample.pdf");

// Get fonts
PdfFontCollection fonts = pdf.Fonts;

// Unembed a font
pdf.Fonts[0].Unembed();
$vbLabelText   $csharpLabel

If uncommon fonts lack fallbacks after unembedding, they may appear corrupted in the output PDF. Check if Adobe shows the same issue—if so, this is expected behavior. If not, contact support for investigation. Corrupted fonts appear as follows:

Adobe Acrobat font error dialog showing missing AAAAAA+Impact font warning with garbled text display

How Do I Replace Fonts in PDF Documents?

Font replacement preserves original font data structure, including styling and character encoding, while substituting the specified font. Ensure new fonts align well with originals. This feature is useful when editing PDFs or standardizing fonts across documents.

In rare cases, visual results may not perfectly match. This is a current limitation of the font replacement method.

:path=/static-assets/pdf/content-code-examples/how-to/manage-font-replace-font.cs
using IronPdf;
using IronPdf.Fonts;
using System.Linq;

// Import PDF
PdfDocument pdf = PdfDocument.FromFile("sample.pdf");

byte[] fontData = System.IO.File.ReadAllBytes("dir/to/font.ttf");
// Get and replace Font
pdf.Fonts["Courier"].ReplaceWith(fontData);
$vbLabelText   $csharpLabel

What Are the 14 Standard PDF Fonts?

The 14 standard fonts (Base 14 Fonts or Standard Type 1 Fonts) are widely supported in PDF viewers and don't require embedding. The PDF standard guarantees these fonts are available when working with PDF documents. These fonts are essential for maintaining compatibility when creating PDFs from various sources.

  • Courier
  • Courier-Bold
  • Courier-Oblique
  • Courier-BoldOblique
  • Helvetica
  • Helvetica-Bold
  • Helvetica-Oblique
  • Helvetica-BoldOblique
  • Times-Roman
  • Times-Bold
  • Times-Italic
  • Times-BoldItalic
  • Symbol
  • ZapfDingbats

Which font names map to standard fonts?

Multiple string names point to the same standard font for convenience. This mapping system ensures compatibility when working with different PDF tools and when merging or splitting PDFs.

Map to Courier

  • StandardFont.Courier
    • Courier
    • CourierNew
    • CourierNewPSMT
    • CourierStd

Map to Courier-Bold

  • StandardFont.CourierBold
    • Courier,Bold
    • Courier-Bold
    • CourierBold
    • CourierNew,Bold
    • CourierNew-Bold
    • CourierNewBold
    • CourierNewPS-BoldMT
    • CourierStd-Bold

Map to Courier-Oblique

  • StandardFont.CourierOblique
    • Courier,Italic
    • Courier-Oblique
    • CourierItalic
    • CourierNew,Italic
    • CourierNew-Italic
    • CourierNewItalic
    • CourierNewPS-ItalicMT
    • CourierStd-Oblique

Map to Courier-BoldOblique

  • StandardFont.CourierBoldOblique
    • Courier,BoldItalic
    • Courier-BoldOblique
    • CourierBoldItalic
    • CourierNew,BoldItalic
    • CourierNew-BoldItalic
    • CourierNewBoldItalic
    • CourierNewPS-BoldItalicMT
    • CourierStd-BoldOblique

Map to Helvetica

  • StandardFont.Helvetica
    • Arial
    • ArialMT
    • Helvetica

Map to Helvetica-Bold

  • StandardFont.HelveticaBold
    • Arial,Bold
    • Arial-Bold
    • Arial-BoldMT
    • ArialBold
    • ArialMT,Bold
    • ArialRoundedMTBold
    • Helvetica,Bold
    • Helvetica-Bold
    • HelveticaBold

Map to Helvetica-Oblique

  • StandardFont.HelveticaOblique
    • Arial,Italic
    • Arial-Italic
    • Arial-ItalicMT
    • ArialItalic
    • ArialMT,Italic
    • Helvetica,Italic
    • Helvetica-Italic
    • Helvetica-Oblique
    • HelveticaItalic

Map to Helvetica-BoldOblique

  • StandardFont.HelveticaBoldOblique
    • Arial,BoldItalic
    • Arial-BoldItalic
    • Arial-BoldItalicMT
    • ArialBoldItalic
    • ArialMT,BoldItalic
    • Helvetica,BoldItalic
    • Helvetica-BoldItalic
    • Helvetica-BoldOblique
    • HelveticaBoldItalic

Map to Times-Roman

  • StandardFont.Times
    • Times-Roman
    • TimesNewRoman
    • TimesNewRomanPS
    • TimesNewRomanPSMT

Map to Times-Bold

  • StandardFont.TimesBold
    • Times-Bold
    • TimesBold
    • TimesNewRoman,Bold
    • TimesNewRoman-Bold
    • TimesNewRomanBold
    • TimesNewRomanPS-Bold
    • TimesNewRomanPS-BoldMT
    • TimesNewRomanPSMT,Bold

Map to Times-Italic

  • StandardFont.TimesOblique
    • Times-Italic
    • TimesItalic
    • TimesNewRoman,Italic
    • TimesNewRoman-Italic
    • TimesNewRomanItalic
    • TimesNewRomanPS-Italic
    • TimesNewRomanPS-ItalicMT
    • TimesNewRomanPSMT,Italic

Map to Times-BoldItalic

  • StandardFont.TimesBoldOblique
    • Times-BoldItalic
    • TimesBoldItalic
    • TimesNewRoman,BoldItalic
    • TimesNewRoman-BoldItalic
    • TimesNewRomanBoldItalic
    • TimesNewRomanPS-BoldItalic
    • TimesNewRomanPS-BoldItalicMT
    • TimesNewRomanPSMT,BoldItalic

Map to Symbol

  • StandardFont.Symbol
    • Symbol
    • SymbolMT

Map to ZapfDingbats

  • StandardFont.Dingbats
    • ZapfDingbats

Frequently Asked Questions

How do I embed custom fonts in PDF documents using C#?

With IronPDF, you can embed custom fonts by using the Add method on the Fonts collection, followed by the Embed method. Simply load your font file as a byte array and add it to the PDF: pdf.Fonts.Add("MyCustomFont", File.ReadAllBytes("MyCustomFont.ttf")).Embed(). This ensures your PDFs display correctly across all platforms.

How can I retrieve all fonts from an existing PDF document?

IronPDF provides access to all document fonts through the Fonts property, which returns a PdfFontCollection object. You can iterate through this collection to retrieve font information including font names, embedding status, and font types, making it easy to analyze document structure and font usage.

What's the best way to find a specific font by name in a PDF?

IronPDF allows you to find specific fonts using the PdfFontCollection object. You can search for fonts by specifying the font name, which gives you access to font objects and their properties. This feature is particularly useful when you need to replace or modify specific fonts in your PDF documents.

Can I remove embedded fonts to reduce PDF file size?

Yes, IronPDF provides the Unembed method that allows you to remove embedded fonts from PDF documents. This can significantly reduce file size while maintaining the document's structure, though it may affect how the PDF displays on systems without the required fonts installed.

How do I replace fonts in existing PDF documents?

IronPDF offers a Replace method that makes font replacement straightforward. You can easily swap out existing fonts with new ones throughout your PDF document, which is useful for maintaining brand consistency or updating legacy documents with modern typefaces.

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 17,012,929 | Version: 2025.12 just released