PdfiumViewer
PdfiumViewer copied to clipboard
Program crashes on image export
Hello,
I render pages to images from the attached PDF file. All images are exported nicely. But when disposing document object, the program crashes. There is no way to handle the exception, it suddenly crashes. Please mind that the below code works fine in most of my PDFs, it only crashes for this particular one. pdfFile.pdf
Here is my code for image rendering;
using (var document = PdfDocument.Load(pdfFile))
{
for (var pageNumber = 0; pageNumber < document.PageCount; pageNumber++)
{
var targetFile = System.IO.Path.Combine(targetPath, string.Format("{0:000}", pageNumber + 1));
using (var image= document.Render(pageNumber, (int)document.PageSizes[pageNumber].Width, (int)document.PageSizes[pageNumber].Height, 96, 96, false))
{
image.Save(targetFile + ".jpg", ImageFormat.Jpeg);
}
}
} // This is where the program crashes
Thanks.