In certain cases, you may need to convert the slides in PowerPoint presentations to images. For example, to embed presentations in your web or desktop applications, to generate thumbnails, etc. PNG is one of the most popular image formats which uses lossless compression. Therefore, in this article, you will learn how to convert slides in PowerPoint PPTX or PPT to PNG images using C#.
C# API for PowerPoint to PNG Conversion
In order to convert the PPTX or PPT presentations to PNG, we will use Aspose.Slides for .NET. It is a feature-rich API that lets you create, modify and convert PowerPoint and OpenOffice presentations using C#. You can either download the API or install it using NuGet.
PM> Install-Package Aspose.Slides.NET
Convert PowerPoint PPTX or PPT to PNG in C#
The following are the steps to convert slides in a PowerPoint PPTX to PNG images using C#.
- First, create an instance of the Presentation class to load the presentation.
- Loop through each ISlide in Presentation.Slides collection.
- Define the dimensions of the resultant PNG image.
- Generate image of the each slide using ISlide.GetThumbnail(float ScaleX, float ScaleY) method and get the reference of image into a Bitmap object.
- Finally, save image as PNG using Bitmap.Save(String, System.Drawing.Imaging.ImageFormat.Png) method.
The following code sample shows how to convert a PowerPoint PPTX to PNG.
Get a Free API License
You can use Aspose.Slides for .NET without evaluation limitations by requesting a temporary license.
Online Demo
Try the online PowerPoint to PNG converter, which is based on Aspose.Slides.
Conclusion
In this article, you have learned how to convert slides in PowerPoint PPTX or PPT to PNG using C#. You can simply install the API and use the provided code in your .NET applications. In addition, you can visit the documentation to explore other features of API. Also, you can feel free to let us know about your queries via our forum.