【发布时间】:2020-05-10 13:46:12
【问题描述】:
当我调试我的应用程序时,在创建 XFont 对象时出现异常。知道有什么问题吗? 在我在 github 等上找到的所有示例中,它与下面的代码完全相同。
System.TypeInitializationException: '类型初始化器 'PdfSharpCore.Utils.FontResolver' 抛出异常。'
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("Test of PdfSharp on Android", font,
new XSolidBrush(XColor.FromArgb(0, 0, 0)),
10, 130);
// Save the document...
document.Save(Path.Combine(Path.GetTempPath(), Name));
【问题讨论】:
-
你能解决这个问题吗?我在 Android 上遇到了同样的问题,但在 UWP 上没有问题。
标签: c# android xamarin.forms pdfsharp