Con*_*dde 14 c# itext7 maui visual-studio-2022
返回时返回错误:Unknown PdfException。- - > System.NotSupportedException:itext7.bouncy-castle-adapter 或itext7。bouncy-castle-fips-adap...在线
Var writer = new PdfWriter(stream);
Run Code Online (Sandbox Code Playgroud)
我的代码是尝试使用 itext7 扩展名创建一个 pdf 文件。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;
}
}
Run Code Online (Sandbox Code Playgroud)
Akt*_*ter 33
发生这种情况的原因是从 8.0 版本开始,iText7 在处理 bouncy-castle 依赖项的方式上做了几个重大的突破性改变。我假设你的 itext7 版本低于 8。所以,
为了解决这个问题,您需要安装另一个Nuget包:
如果您需要更全面的解决方案(包括图像),您还可以查看此答案。
| 归档时间: |
|
| 查看次数: |
18243 次 |
| 最近记录: |