我有一个打印过程,我们不允许使用字体替换来保持文档的完整性。唯一的方法是确保所有字体都被嵌入。我在调用FontFactory.GetFont(字符串字体名,字符串编码,bool嵌入,浮点大小)过载时指定嵌入选项。下面的代码是我用来试图找出解决方案的测试代码。不幸的是,生成的pdf没有嵌入字体。未嵌入ItextSharp中的字体
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,您的字体路径是错误的。 –