In some cases, you may need to convert slides from a PowerPoint presentation to images. For example, embed presentations, generate thumbnails, and so on in your Web or desktop applications. PNG is one of the most popular image formats using lossless compression. So in this article, you’ll learn how to convert slides in PowerPoint PPTX or PPT to PNG images using C#.

  • Convert PowerPoint PPTX or PPT to PNG

To convert PPTX or PPT presentations to PNG, we’ll use Aspose.Slides for.net, a featured-rich API that lets you create, modify, and convert PowerPoint and OpenOffice presentations using C#.

>> You can download the latest version of Aspose.Slides for the test experience.

Convert PowerPoint PPTX or PPT to PNG in C#

Here are the steps to convert slides in PowerPoint PPTX to PNG images using C#.

  • First, create an instance of the Presentation class to load the Presentation.
  • Loop through each I slide-like Presentation.Slides collection.
  • Defines the size of the generated PNG image.
  • Use the islide.getThumbnail (Float ScaleX, float ScaleY) method to generate an image for each slide and place a reference to the image into a Bitmap object.
  • Finally, using the Bitmap. The Save (String, System. Drawing. Imaging. ImageFormat. Png) method will be saved as a Png image.

The following code example shows how to convert PowerPoint PPTX to PNG.

// Load PowerPoint presentation using (Presentation pres = new Presentation("presentation.pptx")) { // User defined dimension int desiredX = 1200; int desiredY = 800; / / Getting scaled the value of X and Y float ScaleX = (float) (1.0 / pres. SlideSize. Size, Width) * desiredX; Float ScaleY = (float) (1.0 / pres. SlideSize. Size, Height) * desiredY; foreach (ISlide sld in pres.Slides) { // Create a full scale image Bitmap bmp = sld.GetThumbnail(ScaleX, ScaleY); // Save the image to disk in PNG format bmp.Save(String.Format("slide_{0}.png", sld.SlideNumber), System.Drawing.Imaging.ImageFormat.Png); }}Copy the code

If you have any questions or requirements, please feel free to join the Aspose Technology Exchange Group (761297826), we are happy to provide you with inquiries and consultation.