I found another problem that Spire.PDF hang when extracting images. No error is thrown, the application stays on ExtractImages forever. I created this as a separate thread with the ExtractText() issue so it is easier to follow. The environment is
- Window 10, Australia/English
- Spire.PDF version 4.2.4
- PDF file
- Code
- Code: Select all
//Instantiate an object of Spire.Pdf.PdfDocument
PdfDocument doc = new PdfDocument();
//Load a PDF file
doc.LoadFromFile("../../PDFs/crashed service/hang ocr-9e0f63cd-2a3c-4cd8-9f85-93db0aabcbde.pdf");
List<Image> ListImage = new List<Image>();
for (int i = 0; i < doc.Pages.Count; i++)
{
// Get an object of Spire.Pdf.PdfPageBase
PdfPageBase page = doc.Pages[i];
// Extract images from Spire.Pdf.PdfPageBase
Image[] images = page.ExtractImages(); //hang here
if (images != null && images.Length > 0)
{
ListImage.AddRange(images);
}
}
if (ListImage.Count > 0)
{
for (int i = 0; i < ListImage.Count; i++)
{
Image image = ListImage[i];
image.Save("image" + (i + 1).ToString() + ".png", System.Drawing.Imaging.ImageFormat.Png);
}
System.Diagnostics.Process.Start("image1.png");
}
//extract text
StringBuilder content = new StringBuilder();
foreach (PdfPageBase page in doc.Pages)
content.Append(page.ExtractText());
var text = content.ToString();
Can you please investigate?
Cheers,
Tung