IText7 Version : 7.1.14
我们检测到不能在IText7 5中使用.NET 5:
private byte[] BuildPDF()
{
using(var stream = new MemoryStream())
{
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(stream));
Document doc = new Document(pdfDoc);
Table table = new Table(UnitValue.CreatePercentArray(8)).UseAllAvailableWidth();
for (int i = 0; i < 16; i++)
{
table.AddCell("hi");
}
doc.Add(table);
doc.Close();
return stream.ToArray();
}
}
这个简单的代码正在.NET Core3.1Project上工作,但是不是工作在.NET 5项目上。
引发的Exception
如下所示:
An unhandled exception occurred while processing the request.
FileNotFoundException: Could not load file or assembly 'Microsoft.DotNet.PlatformAbstractions,
Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
The system cannot find the file specified.
iText.IO.Util.ResourceUtil.LoadITextResourceAssemblies()
TypeInitializationException: The type initializer for 'iText.IO.Util.ResourceUtil' threw an exception.
iText.IO.Font.Type1Parser.GetMetricsFile()
一个.dll找不到,但是如何解决这个问题,或者如何向IText7报告一个bug?
发布于 2021-03-04 07:40:47
您可以在上面的链接上手动安装https://www.nuget.org/packages/Microsoft.DotNet.PlatformAbstractions/ (Microsoft.DotNet.PlatformAbstractions)数据包,也可以从项目解决方案上的Manage包中手动安装。
https://stackoverflow.com/questions/66457984
复制相似问题