asp.net-mvc - ASP.NET MVC PDFsharp 生成 PDF : cannot add font

标签 asp.net-mvc azure fonts pdf-generation pdfsharp

在我的 ASP.NET MVC 5 应用程序中,我尝试生成简单的 PDF。我的问题是,将应用程序部署到 Azure 后,生成 PDF 的功能停止工作。有一个异常(exception):“无法检索字体数据。”。所以应用程序服务器看不到我使用的字体(Times New Roman)。我的问题是如何修复它?在我的项目中,我添加了一个名为“Fonts”的文件夹,其中包含 4 种 Times New Roman 字体。在代码中我只使用一种字体:

XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
string Font = HostingEnvironment.MapPath(@"~/Fonts/TIMESBD.TTF");
XFont BasicFont = new XFont(Font, 16, XFontStyle.Regular, options);

本地主机上不存在该问题。我认为我应该以某种方式在我的应用程序中“注册”我的字体,但我不知道如何。

最佳答案

确保服务器上安装了 Time New Roman 字体 - 或使用私有(private)字体(在您的项目中包含该字体)。

将Time New Roman字体的全部权限授予用户组并重新启动服务器。

看看这是否有帮助。

关于asp.net-mvc - ASP.NET MVC PDFsharp 生成 PDF : cannot add font,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34937638/

相关文章:

java - 突出显示阿拉伯语元音

javascript - 从 DropDown 中选择选项并在另一个文本字段中自动设置值 ASP .NET MVC

asp.net-mvc - List<dynamic> 的奇怪 Razor 行为

azure - 如何通过 Azure DevOps REST API 上传 'secret file'?

azure - 如何使用 Graph(或其他 MS API)检索 Azure 企业应用程序对象 ID

c# - 如何以编程方式使用通过 AddFontResource() 安装的字体?

c# - MVC 多个表单合并为 1 个 Controller

c# - 引用另一个程序集中的类型导致 Razor.Compile() 中出现 "the type is defined in an assembly that is not referenced"错误

Azure 流分析唯一 EventId 属性为 NULL

ios - 如何在 WatchKit 中使用等宽字体