Fonts in IronPDF: Best Practices

This article was translated from English: Does it need improvement?
Translated
View the article in English

IronPDF会嵌入字体吗?

假设字体的嵌入属性设置为可编辑,所有在您的HTML中使用的字体(子集)都会自动嵌入到PDF中。 这确保了PDF以相同的字体显示,防止任何不一致。

IronPDF可以移除字体吗?

是的,IronPDF可以移除字体。 技术上,它通过取消嵌入字体实现这一点。 有关如何管理和取消嵌入PDF中字体的更详细说明,请访问以下操作指南文章:'如何管理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
pdf.UnembedAllFonts();

// 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
pdf.UnembedAllFonts();

// Save the updated PDF document
pdf.SaveAs("document-without-embedded-fonts.pdf");
' Example of code to unembed fonts from a PDF using IronPDF
Imports IronPdf

' Load the existing PDF document
Private pdf = PdfDocument.FromFile("existing-document.pdf")

' Remove fonts by unembedding them
pdf.UnembedAllFonts()

' Save the updated PDF document
pdf.SaveAs("document-without-embedded-fonts.pdf")
$vbLabelText   $csharpLabel

我可以在我的PDF中嵌入整个字体吗?

是的,IronPDF允许您在PDF文档中嵌入字体。 嵌入字体确保视觉一致性,因为无论查看者的系统上是否安装了所需字体,文档都将以所需字体显示。 请注意,嵌入字体可能会增加PDF的文件大小。 有关如何管理和嵌入PDF中字体的更详细说明,请访问操作指南文章:'如何管理PDF中的字体'

// Example of code to embed fonts in a PDF using IronPDF
using IronPdf;

// Create a new PdfDocument or load an existing one
var pdf = new IronPdf.HtmlToPdf().RenderHtmlAsPdf("<h1>Hello World</h1>");

// Ensure all fonts are embedded
pdf.SaveAs("document-with-embedded-fonts.pdf", new PdfSaveOptions
{
    EmbedFonts.Enabled = true
});
// Example of code to embed fonts in a PDF using IronPDF
using IronPdf;

// Create a new PdfDocument or load an existing one
var pdf = new IronPdf.HtmlToPdf().RenderHtmlAsPdf("<h1>Hello World</h1>");

// Ensure all fonts are embedded
pdf.SaveAs("document-with-embedded-fonts.pdf", new PdfSaveOptions
{
    EmbedFonts.Enabled = true
});
' Example of code to embed fonts in a PDF using IronPDF
Imports IronPdf

' Create a new PdfDocument or load an existing one
Private pdf = (New IronPdf.HtmlToPdf()).RenderHtmlAsPdf("<h1>Hello World</h1>")

' Ensure all fonts are embedded
pdf.SaveAs("document-with-embedded-fonts.pdf", New PdfSaveOptions With {.EmbedFonts.Enabled = True})
$vbLabelText   $csharpLabel
Curtis Chau
技术作家

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。

准备开始了吗?
Nuget 下载 16,154,058 | 版本: 2025.11 刚刚发布