[英]How do I resolve Unknown PdfException when using itext7 in. net maui
Error returned on return: Unknown PdfException.返回时返回错误:Unknown PdfException。 - - > System.NotSupportedException:Either itext7.bouncy-castle-adapter or itext7. - -> System.NotSupportedException:Either itext7.bouncy-castle-adapter 或 itext7。 bouncy-castle-fips-adap... On line bouncy-castle-fips-adap ...在线
Var writer = new PdfWriter(stream);
My code is try to get create a pdf file using itext7 extension.我的代码是尝试使用 itext7 扩展名创建一个 pdf 文件。 In.net maui for mobile apps. In.net maui 用于移动应用程序。
public static MemoryStream CreatePdf()
{
try
{
using (var stream = new MemoryStream())
{
var writer = new PdfWriter(stream);
var pdf = new PdfDocument(writer);
var document = new Document(pdf);
var paragraph = new Paragraph("hello");
document.Add(paragraph);
document.Close();
stream.Position = 0;
return stream;
}
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
return null;
}
}
The reason it's occurring because from version 8.0, iText7 did several major breaking changes in the way they handle bouncy-castle dependencies.它发生的原因是因为从 8.0 版开始,iText7 在处理 bouncy-castle 依赖项的方式上做了几个重大的突破性改变。 I assumed, your itext7 version is less than 8. So,我假设,您的 itext7 版本小于 8。所以,
For resolving this issue, you need to install another Nuget package:要解决此问题,您需要安装另一个 Nuget package:
You can also check-out this answer, if you need more comprehensive solution including images.如果您需要更全面的解决方案(包括图像),您也可以查看此答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.