Updated December 10, 2024
Share:

Fonts in IronPDF: Best Practices

Does IronPDF embed fonts?

All font (subsets) used inside your HTML are automatically embedded inside PDF. (Assuming the Font embed property of the font is set to Editable).

Can IronPDF remove fonts?

Yes, IronPDF can remove fonts. Technically, it unembeds the font. Please visit the following How-to article to learn more about fonts: 'How to Manage Fonts in PDF'

: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();

Can I embed an entire font in my PDF?

Yes, IronPDF can embed fonts. Embedding fonts in PDFs ensures visual consistency without requiring font installation but will increase file size. Please visit the following How-to article to learn more about fonts: 'How to Manage Fonts in PDF'

: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");
pdf.Fonts.Add(fontData);

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