返回时返回错误: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)