I am currently trying to interact with PDF files using a library called IronPdf. I created a simple Console Application and managed to follow their tutorial by creating a HTML file, writing to it, saving it as a PDF and accessing that PDF.
However whenever I try to further work with that pdf I always get an ExecutionEngineException with the following message:
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[])
This is my code:
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());
}
The exception gets thrown on the last line, when I'm trying to extract text from the file. I have already tried to look for some clues online and it led me to this post however nothing seems to work.
My questions would be:
- Why does this error get thrown?
- How do I fix it?
- What does
0x80131506
stand for?