【发布时间】:2021-10-13 23:40:26
【问题描述】:
我目前正在尝试使用名为 IronPdf 的库与 PDF 文件进行交互。我创建了一个简单的控制台应用程序,并通过创建一个 HTML 文件、写入它、将其保存为 PDF 并访问该 PDF 来设法遵循他们的 tutorial。
但是,每当我尝试进一步使用该 pdf 文件时,我总是会收到带有以下消息的 ExecutionEngineException:
Fatal error. Internal CLR error. (0x80131506)
at IronPdf.Pdfium.NativeMethods.FPDFDOC_ExitFormFillEnvironment(IntPtr)
at IronPdf.Pdfium.PdfFile.Dispose(Boolean)
at IronPdf.Pdfium.PdfDocument.Dispose(Boolean)
at IronPdf.Pdfium.PdfDocument.Dispose()
at IronPdf.PdfDocument.lymdps(System.Collections.Generic.IEnumerable`1<Int32>)
at IronPdf.PdfDocument.ExtractTextFromPages(Int32, Int32)
at IronPdf.PdfDocument.ExtractAllText()
at IronPdfDemo.Program.Main(System.String[])
这是我的代码:
using IronPdf;
...
static void Main(string[] args)
{
//create new html file
var htmlToPdf = new HtmlToPdf();
htmlToPdf.PrintOptions.FirstPageNumber = 1;
//add text to html and save as pdf
htmlToPdf.RenderHtmlAsPdf("Hello World").SaveAs("html-string.pdf");
//get pdf
var pdf = PdfDocument.FromFile("html-string.pdf");
//print out number of pages, should be 1
Console.WriteLine(pdf.PageCount);
//write text from pdf
Console.WriteLine(pdf.ExtractAllText());
}
当我试图从文件中提取文本时,在最后一行抛出异常。我已经尝试在网上寻找一些线索,并找到了this post,但似乎没有任何效果。
我的问题是:
- 为什么会抛出这个错误?
- 如何解决?
-
0x80131506代表什么?
【问题讨论】:
标签: c# exception clr .net-5 ironpdf