Fonts in IronPDF: Best Practices
Does IronPDF embed fonts?
All font (subsets) used inside your HTML are automatically embedded inside the PDF, assuming the Font embed property of the font is set to Editable. This ensures that the PDF is displayed with the same fonts, preventing any discrepancies.
Can IronPDF remove fonts?
Yes, IronPDF can remove fonts. Technically, it achieves this by unembedding the font. For more detailed instructions on how to manage and unembed fonts from PDFs, please visit the following How-to article: 'How to Manage Fonts in PDF'
// Example of code to unembed fonts from a PDF using IronPDF
using IronPdf;
// Load the existing PDF document
var pdf = PdfDocument.FromFile("existing-document.pdf");
// Remove fonts by unembedding them
foreach (var font in pdf.Fonts)
{
font.Unembed();
}
// Save the updated PDF document
pdf.SaveAs("document-without-embedded-fonts.pdf");
// Example of code to unembed fonts from a PDF using IronPDF
using IronPdf;
// Load the existing PDF document
var pdf = PdfDocument.FromFile("existing-document.pdf");
// Remove fonts by unembedding them
foreach (var font in pdf.Fonts)
{
font.Unembed();
}
// Save the updated PDF document
pdf.SaveAs("document-without-embedded-fonts.pdf");
Imports IronPdf
' Load the existing PDF document
Dim pdf = PdfDocument.FromFile("existing-document.pdf")
' Remove fonts by unembedding them
For Each font In pdf.Fonts
font.Unembed()
Next
' Save the updated PDF document
pdf.SaveAs("document-without-embedded-fonts.pdf")
Can I embed an entire font in my PDF?
Yes, IronPDF allows you to embed fonts in your PDF documents. Embedding fonts ensures visual consistency, as the document will be displayed with the desired fonts regardless of whether they are installed on the viewer's system. Note that embedding fonts can increase the file size of the PDF. For more detailed instructions on how to manage and embed fonts in PDFs, visit the how-to article: 'How to Manage Fonts in PDF'
// Example of code to embed fonts in a PDF using IronPDF
using IronPdf;
// Create a new PdfDocument or load an existing one
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
// Embed a font into the document, then save
pdf.Fonts.Add(File.ReadAllBytes("MyFont.ttf")).Embed();
pdf.SaveAs("document-with-embedded-fonts.pdf");
// Example of code to embed fonts in a PDF using IronPDF
using IronPdf;
// Create a new PdfDocument or load an existing one
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
// Embed a font into the document, then save
pdf.Fonts.Add(File.ReadAllBytes("MyFont.ttf")).Embed();
pdf.SaveAs("document-with-embedded-fonts.pdf");
Imports IronPdf
' Create a new PdfDocument or load an existing one
Dim renderer As New ChromePdfRenderer()
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>")
' Embed a font into the document, then save
pdf.Fonts.Add(File.ReadAllBytes("MyFont.ttf")).Embed()
pdf.SaveAs("document-with-embedded-fonts.pdf")

