【发布时间】:2017-12-11 12:33:42
【问题描述】:
我在 itext PDF 生成器中为 Xamarin 表单应用程序(Android 和 IOS)尝试了 POC,
检查的场景: itext sharp 版本:5.5.21 - 在 PCL 项目和本机项目中都运行良好。 itext7 版本:7.1.0 - 出现以下错误
System.TypeInitializationException: The type initializer for
'iText.IO.Util.ResourceUtil' threw an exception. --->
System.TypeInitializationException: The type initializer for
'Microsoft.Extensions.DependencyModel.DependencyContextLoader' threw an
exception. ---> System.TypeInitializationException: The type initializer for
'Microsoft.Extensions.DependencyModel.DependencyContextPaths' threw an
exception. ---> System.NotImplementedException: The method or operation is not
implemented.
在论坛中,有人说这已在以前的版本中修复。我之前需要初始化的任何东西。附上下面尝试过的代码,
PdfDocument pdf = new PdfDocument(new PdfWriter(fs, new WriterProperties().AddXmpMetadata()));
Document document = new Document(pdf);
pdf.SetTagged();
pdf.GetCatalog().SetLang(new PdfString("en-US"));
pdf.GetCatalog().SetViewerPreferences(new PdfViewerPreferences().SetDisplayDocTitle(true));
PdfDocumentInfo info = pdf.GetDocumentInfo();
info.SetTitle("iText7 PDF/UA example");
PdfFont font = PdfFontFactory.CreateFont(FONT, PdfEncodings.WINANSI, true);
Paragraph p = new Paragraph();
p.SetFont(font);
p.Add(new Text("The quick brown "));
document.Add(p);
document.Close();
当断点命中 PdfFont 时,它会引发上述错误。
【问题讨论】:
标签: xamarin.ios xamarin.forms xamarin.android itext itext7