Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Fri Feb 18, 2022 2:38 pm

Hey.

I have a problem when saving slides to images using SaveAsImage with .Net Core under Linux.
Saving single slides works fine, but when I try to save all slides to images in a loop:

Code: Select all
For Each slide As ISlide In c_PresentationDocument.Slides

   ' Export thumbnails
   Console.WriteLine("Generating thumbnail for slide " & i & "/" & c_PresentationDocument.Slides.Count)

   strNumber = i.ToString

   ' Insert leading zeros
   While strNumber.Length < c_PresentationDocument.Slides.Count.ToString.Length
      strNumber = "0" & strNumber
   End While

   ' Export thumbnail
   sImageName = filename & "_Slide" & strNumber & ".jpg"

   img = slide.SaveAsImage()
   img.Save(glb.strPathTarget & sImageName, System.Drawing.Imaging.ImageFormat.Jpeg)

   i = i + 1

Next ' slide


I get the following error:

Unhandled exception. System.InvalidOperationException: Object is currently in use elsewhere.
at System.Drawing.SafeNativeMethods.Gdip.CheckStatus(Int32 status)
at System.Drawing.Graphics.Dispose()
at System.Drawing.Graphics.Finalize()


When I run the program under Windows, it works flawlessly. The error only occurs when run under Linux (Ubuntu 20.04).
Stepwise debugging shows that the exception occurs upon slide.SaveAsImage()

Can you imagine what is happening here, and how to get around it?

Kind Thanks.

arnd
 
Posts: 3
Joined: Mon Apr 23, 2018 10:40 am

Mon Feb 21, 2022 2:23 am

Hello,

Thanks for your inquiry!

I simulated a PPTX file and did an initial test in .NET Core 3.1 application with the code you provided, but did not reproduce the issue.

To help further look into your issue, please share us with the following information. Thanks in advance.

1. Your input files.
2. The target framework of your project (E.g. .Net core 3.1)
3. Your project type (E.g. console application)

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon Feb 21, 2022 9:42 am

Hey Marcia.

Kind Thanks for your reply!

The project type of the program containing the cited code is .NET Core 3.1, and it is a console app.
I uploaded the inout PPTX file that was used for testing when the error occurred.

While generating the slide images, two further warnings are issued:

** (process:5001): WARNING **: 10:37:46.666: NOT IMPLEMENTED: GdipWidenPath
** (process:5001): WARNING **: 10:37:48.670: gdip_bitmap_ensure_surface: Unable to create a surface for raw bitmap data of format 0x00030803

Maybe this helps?

Greets,
arnd.

arnd
 
Posts: 3
Joined: Mon Apr 23, 2018 10:40 am

Mon Feb 21, 2022 10:02 am

Hello Arnd,

Thanks for yor feedback!

Sorry that I did not see your PPTX file, could you please upload it again? Or you can send it to us via email (support@e-iceblue.com). Thanks in advance!

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Tue Feb 22, 2022 7:30 am

Hello Arnd,

I have received your email, thanks for sharing more information!

I have reproduced your issue based on your file and logged it in our issue tracking system with the ticket SPIREPPT-1860 for further investigation.

We will let you know if there is any update. Sorry for the inconvenience caused.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Tue Mar 15, 2022 10:34 am

Hello,

Thanks for your patience!
Glad to inform you that we just released Spire.Presentation Pack Hotfix Version:7.3.1 which fixes the exception issue with SPIREPPT-1860.
Please download the new version from the following links to test.

Website link: https://www.e-iceblue.com/Download/download-presentation-for-net-now.html
Nuget link: https://www.nuget.org/packages/Spire.Presentation/7.3.1

In addition, regarding the warning message, after investigation, we found that the warning message was caused by the lack of gdi-related interfaces under linux. It is the underlying warning message, so we can't handle it. Hope you can understand.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Return to Spire.Presentation