Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Feb 09, 2018 3:30 am

Hi there,
I am getting a stackoverflow exception when extract images from the attached pdf.
5cd5a5ce-c89a-4a27-9200-76eb690c9db6.rar


I tried with both latest spire.pdf and free spire.pdf from Nuget. Can you please investigate?

And is this possible that you can release the fix in the free spire.pdf version as well. It hasn't been updated since 2015.

Cheers,
Tung

tungnguyen
 
Posts: 8
Joined: Fri Feb 09, 2018 3:20 am

Fri Feb 09, 2018 8:18 am

Dear Tung,

Thanks for your inquiry.
I have tested your case with the latest Spire.PDF Pack(Hot Fix) Version:4.2.4 on my side, sorry that I didn't reproduce your issue,and I could extract image successfully.
Here is my testing code:
Code: Select all
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile(@"F:\5cd5a5ce-c89a-4a27-9200-76eb690c9db6.pdf");
            PdfPageBase page = doc.Pages[0];
            Image[] images = page.ExtractImages();
            for (int i = 0; i < images.Length; i++)
            {
                Image pdfImage = images[i];
                string imageFile = String.Format("12899-image{0}.png", i);
                pdfImage.Save(imageFile, System.Drawing.Imaging.ImageFormat.Png);
            }

Please make sure whether or not the uploaded file is the correct file which has the issue you mentioned. If so, please provide following information to help us reproduce your issue on my side.
1. The code you were using
2. The information of the latest version you mentioned, e.g. 4.2.4.2040
3. The OS and Region information, e.g. China/Chinese

Please note we don't have the plan to update Free version at present. All fixes and new features are only included in commercial version. Besides, our sales team has sent you a one-month free license of Spire.PDF to help remove the warning message and have a better evaluation on our product.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Sat Feb 10, 2018 4:36 pm

Thanks for your quick response. I can confirm that it is working with the new version 4.2.4 (which was released few hours after I tested extracting the images)

However, it throws an error stackoverflow when it tries to extract text from pdf page (using the same file pdf before)
Code: Select all
            //extract text
            StringBuilder content = new StringBuilder();
            foreach (PdfPageBase page in doc.Pages)
                content.Append(page.ExtractText());
            var text = content.ToString();


Tung

tungnguyen
 
Posts: 8
Joined: Fri Feb 09, 2018 3:20 am

Sat Feb 10, 2018 4:39 pm

And for completeness, I used windows 10, and Region Australia/English.

Cheers,
Tung

tungnguyen
 
Posts: 8
Joined: Fri Feb 09, 2018 3:20 am

Sun Feb 11, 2018 7:34 am

Dear Tung,

Thanks for your feedback.
Unfortunately, I am unable to reproduce your issue on my side. Here is my testing project, please run it on your side and tell us your result.
http://www.e-iceblue.com/downloads/atta ... ctText.zip

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Sun Feb 11, 2018 1:32 pm

Hi Betsy,
Thanks for the response. I realize that it only throws stackoverflow if i try to extract both text and images. Here is the code:

Code: Select all
namespace _12899ExtractText
{
    class Program
    {
        static void Main(string[] args)
        {
            PdfDocument doc = new PdfDocument(@"5cd5a5ce-c89a-4a27-9200-76eb690c9db6.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();
                if (images != null && images.Length > 0)
                {
                    ListImage.AddRange(images);
                }
            }

            //extract text
            StringBuilder content = new StringBuilder();
            foreach (PdfPageBase page in doc.Pages)
                content.Append(page.ExtractText());
            //note there is only an image in your pdf, so the text is null
            var text = content.ToString();
            File.WriteAllText("12899.txt", text);
            System.Diagnostics.Process.Start("12899.txt");
        }
    }
}


Cheers,
Tung

tungnguyen
 
Posts: 8
Joined: Fri Feb 09, 2018 3:20 am

Mon Feb 12, 2018 2:13 am

Dear Tung,

Thanks for your feedback.
I have reproduced the issue and logged it in our bug tracking system. We will let you know when it is fixed.
Sorry for the inconvenience.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Feb 12, 2018 2:27 am

Thanks Betsy.

Cheers,
Tung

tungnguyen
 
Posts: 8
Joined: Fri Feb 09, 2018 3:20 am

Mon Feb 26, 2018 7:56 am

Dear Tung,

Glad to inform you the issue has been fixed in Spire.PDF Pack(Hot Fix) Version:4.2.8.
Looking forward to your feedback.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF