IronPDF 中的字體:最佳實踐

2022年1月19日
已更新 2024年12月10日
分享:
This article was translated from English: Does it need improvement?
Translated
View the article in English

IronPDF是否嵌入字體?

所有字體(子集)在您的HTML中使用的內容將自動嵌入到PDF中。 (假設字體的嵌入屬性設置為可編輯).

IronPDF可以移除字體嗎?

是的,IronPDF可以移除字型。 技術上來說,它會取消嵌入字體。 請訪問以下的操作指南文章,以了解更多關於字體的資訊:'如何管理 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();

我可以在我的PDF中嵌入整個字體嗎?

是的,IronPDF可以嵌入字體。 將字體嵌入PDF中可確保視覺一致性,無需安裝字體,但會增加文件大小。請訪問以下教學文章以了解更多關於字體的信息:'如何管理 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);