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.

Tue Jul 04, 2023 3:34 pm

Hi,

I have some problems converting from a PDF page to image using Spire.Officefor.NETStandard (on versions 8.4.0 and 8.6.0). I have the following code snippet, but the code seems to run into problems when it reaches the SaveAsImage method. It simply hangs for some time until I get a timeout on my request. I've noticed when debugging that the debugger allocates a pretty significant amount of memory when trying to convert the PDF page. It goes from about 10MB to 32GB. I therefore suspect that this has something to do with a memory leak, however I'm not entirely sure. I've attached a sample file in which I experience this bug.

Code: Select all
using (var inputStream = new MemoryStream(Convert.FromBase64String(inputDoc.Content)))
  using (var doc = new PdfDocument(inputStream))
  {
    for (int i = 0; i < doc.Pages.Count; i++)
    {
      using var imgStream = doc.SaveAsImage(i);
      var img = PdfImage.FromStream(imgStream);

      var size = new SizeF(img.Width, img.Height);
      var page = _outputDocument.Pages.Add(size);

      img.Draw(page.Canvas);
    }
  }

TGlinski
 
Posts: 1
Joined: Fri Dec 02, 2022 1:33 pm

Wed Jul 05, 2023 5:57 am

Hello,

Thanks for your inquiry.
I have tested your project using Spire.Officefor.NETStandard (8.6.0), but did not reproduce your issue. The conversion process worked fine in all my tests, and I have attached the result file below. In order to help us investigate your issue quickly and effectively, please provide the following information for our reference. You could send them to us via email (support@e-iceblue.com). Thanks in advance.
1) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).
2) Your application type, such as Console app (.Net5).

Sincerely
Wenly
E-iceblue support team
User avatar

Wenly.Zhang
 
Posts: 149
Joined: Tue May 16, 2023 2:19 am

Wed Jul 05, 2023 9:54 am

Hello,

Thanks for sharing the information via email.
I have tested the code in the .Net6 environment and did reproduce the issue you mentioned. The program does indeed hang for a long time when it reaches the SaveAsImage method. I have logged the issue into our bug tracking system with the ticket number SPIREPDF-6128. Our development team will investigate and fix it. Once it is resolved, I will inform you in time. Sorry for the inconvenience caused.

Sincerely
Wenly
E-iceblue support team
User avatar

Wenly.Zhang
 
Posts: 149
Joined: Tue May 16, 2023 2:19 am

Fri Aug 04, 2023 7:06 am

Hi Wenly

We still have an issue, even though we upgraded to Spire.Officefor.NETStandard 8.7.0, and we are running .NET 7.0.7. On my machine, Spire uses around 11-12GB and takes 5 minutes to produce a result, even though both the input and output pdfs are very small. This is far too long for our customers.

Is there an ETA for a solution?

With regards,
Tórur

torurstrom
 
Posts: 2
Joined: Fri Aug 04, 2023 6:57 am

Fri Aug 04, 2023 9:26 am

Hello,

Thank you for your inquiry.
Our latest version of Spire. Office for. NETStandard is 8.8.0, and we recommend that you use the latest version for advanced testing. If the issue still exists, in order for us to quickly and effectively investigate your issue, please provide the following information for our reference. You could attach them here or send them to us via email (support@e-iceblue.com). Thanks in advance.
1) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).
2) Your sample code and your input file.

Sincerely,
Wenly
E-iceblue support team
User avatar

Wenly.Zhang
 
Posts: 149
Joined: Tue May 16, 2023 2:19 am

Mon Aug 07, 2023 8:56 am

Hi Wenly,

It seems that upgrading to 8.8.0 fixed the issue.

Thank you for your help.

With regards,
Tórur

torurstrom
 
Posts: 2
Joined: Fri Aug 04, 2023 6:57 am

Mon Aug 07, 2023 9:25 am

Hello,

You're welcome.
I'm glad to hear that your issue has been resolved. If you encounter other issues related to our products in the future, please feel free to contact us.
Have a nice day!

Sincerely,
Wenly
E-iceblue support team
User avatar

Wenly.Zhang
 
Posts: 149
Joined: Tue May 16, 2023 2:19 am

Thu Oct 26, 2023 6:01 am

Hello torurstrom,

Thank you for your patience.
Regarding issue SPIREPDF-6128, after conducting investigation and testing, we have found that the latest version of Spire.Office for .NETStandard version 8.9.3, has resolved this issue. Please download this version and perform your tests.
We look forward to receiving your testing feedback.

Website download link: https://www.e-iceblue.com/Download/download-office-for-net-now.html
Nuget download link: https://www.nuget.org/packages/Spire.Officefor.NETStandard/8.9.2

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1652
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDF

cron