我尝试让 PdfSharp 在 Azure 函数中工作 但我的字体有一些问题
// Create a new PDF document
PdfDocument document = new PdfDocument();
document.Info.Title = "Created with PDFsharp";
// Create an empty page
PdfPage page = document.AddPage();
// Get an XGraphics object for drawing
XGraphics gfx = XGraphics.FromPdfPage(page);
// Create a font
XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic);
// Draw the text
gfx.DrawString("Hello, World!", font, XBrushes.Black,
new XRect(0, 0, page.Width, page.Height),
XStringFormats.Center);
这也是 PDFSharp 示例页面中的代码... 在字体行他给了我以下错误......
Exception while executing function: Functions.PDFGenerationFunction. PdfSharp: Internal error. Font data could not retrieved.
我需要引用一些特别的东西吗?或者是否无法在 Azure 函数中执行此操作?
PDFSharp 版本 --> "PDFsharp": "1.32.3057"
和/或在 Azure 函数中生成 PDF 文档的另一种解决方案...
最佳答案
这可能是 Azure Functions 和 Web 应用运行所在的沙箱存在问题。 查看此列表,了解可在沙箱中运行的已知 PDF 库。 https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#unsupported-frameworks
关于azure - 在 Azure 函数中使用字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45162780/