【发布时间】:2016-12-11 21:26:53
【问题描述】:
我有一个打印过程,我们不允许使用字体替换来保持文档的完整性。完成此操作的唯一方法是确保嵌入所有字体。当我调用 FontFactory.GetFont(string fontname,string encoding,bool embedded,float size) 重载时,我指定了嵌入选项。下面的代码是我一直用来尝试找出解决方案的测试代码。不幸的是,生成的 pdf 没有嵌入字体。
public static void TestPDFEmbedd()
{
Document document = new Document();
PdfWriter.GetInstance(document, new FileStream(SystemPaths.SystemPath + "\\Production\\Test.pdf", FileMode.Create));
document.Open();
FontFactory.Register("c:\\windows\\fonts\\tahomabd.ttf","address_font");
Font font = FontFactory.GetFont("address_font",BaseFont.CP1252,true,10f);
document.Add(new Paragraph("Testing 123", font));
document.Close();
}
【问题讨论】:
-
如果您看到 Helvetica 而不是 Tahoma Bold,则您的字体路径是错误的。