Stimulsoft 导出只有正方形的 pdf

Stimulsoft exporting pdf with only squares

我正在 Azure 应用服务上使用 C# WebAPI 运行 中的 Stimulsoft。当我将报告导出为 PDF 时,所有文本都呈现为正方形,就像这样

当导出为 HTML 时报告是正确的。在本地或 Azure 中的虚拟机中,pdf 文件是正确的,问题仅出现在 Azure 应用服务上。

这是我用来导出 pdf 的代码。我使用的字体是Arial,有些部分有粗体或斜体。

var settings = new StiPdfExportSettings() { ImageQuality = 1.0f, ImageResolution = 300, EmbeddedFonts = true, StandardPdfFonts = true };

                report.ExportDocument(StiExportFormat.Pdf, ms, settings);

谁能帮帮我?

我已经解决了更改 pdf 设置以像这样导出的问题

var settings = new StiPdfExportSettings() { ImageQuality = 1.0f, ImageResolution = 300, EmbeddedFonts = false, UseUnicode = false, StandardPdfFonts = true };

这仅适用于 StandardPdfFonts = true 和 EmbeddedFonts = false,只有 UseUnicode = false 不起作用

字体问题是由 Azure 网站服务的限制引起的:它只能访问有限的字体集,不能 providing access (confirmed by another MS employee too) 访问字体呈现所需的 GDI+ 子系统设备上下文。

如果您尝试操纵字体或其参数,您可能还会期望 General GDI+ error 发生。

建议的解决方案是

PDF 导出需要访问报表中使用的字体文件。 Stimulsoft 报表引擎使用 GDI+ 访问有关字体的必要信息。

Azure 网站对访问 GDI+ 有限制。

一种出路是使用 Standard PDF fonts

或者您可以为本地计算机上的 PDF 导出准备必要的字体。在这种情况下,您不需要访问 GDI+ 函数。

工作原理:

  • 使用 the FontInfoCreator utility,您创建字体文件 (*.fiz)

  • 在应用程序的初始化部分将这些文件加载​​到字体存储区。

示例代码:

Stimulsoft.Report.Export.FontsInfoStore.LoadFontInfoToStore("Arial", @"fontstore\Arial.fiz");