经过一些转换,我们正在使用 Spire.Xls 库将 Excel 文件转换为 PDF。在我们将 Spire 升级到最新版本之前,一切正常。
该文档生成良好,但它没有呈现我们在 Excel 模板中指定的 Barcode 字体。它改为显示数字。
我们在 Azure App 服务中托管应用程序,因此我们无法在那里安装这些字体。经过最新的指导方针之后,该框架似乎具有将私有字体嵌入到 excel 的新方法,但是似乎存在与字体缓存相关的一些问题。添加自定义字体后,条形码会出现在生成的 PDF 中。但是,它只出现在第一个请求中。第一次请求后的所有后续请求都没有加载具有正确条形码的文档。它改为显示纯数字。
这是我们根据最新文档尝试的代码片段。
var fontPath = HttpContext.Current.Server.MapPath("~/ExcelDocuments/idautomationhc39m_free_version.ttf");
Workbook document = new Workbook();
var fontArr = new string[] { fontPath };
document.CustomFontFilePaths = fontArr;
var res = document.GetCustomFontParsedResult();
document.LoadFromFile(template);
//Further processing
document.SaveToFile("d:\\test.pdf", Spire.Xls.FileFormat.PDF);
有没有人有同样的问题?