Convert PowerPoint to Image

There could be various scenarios when you need to convert PowerPoint PPT or PPTX to JPG images. For example, you may need to slide show the PPT/PPTX presentation in read-only mode within your application or you may want to generate the thumbnail for every slide of the PowerPoint presentation and etc. In order to automate PowerPoint to JPG conversion, I’ll show you how to convert PPT or PPTX slides to JPG images programmatically in C# .NET.

Converting PPT or PPTX to JPG Images in C#

In order to convert PPT(X) to JPG images, we’ll use Aspose.Slides for .NET which is a complete .NET package for PowerPoint automation. The API provides high-quality conversion of PowerPoint presentations to various file formats including JPG.

You can either download and reference the API’s DLL or install the package using NuGet Package Manager or Package Manager Console.

Using NuGet Package Manager

PPT to JPG in C#

Using the Package Manager Console

PM> Install-Package Aspose.Slides

Convert PowerPoint PPT to JPG in C#

The following are the steps to convert PPT to JPG using Aspose.Slides for .NET.

The following code sample shows how to convert PPT to JPG images in C#.

using (Presentation pres = new Presentation("PowerPoint-Presentation.ppt"))
{
foreach (ISlide sld in pres.Slides)
{
// Create a full scale image
Bitmap bmp = sld.GetThumbnail(1f, 1f);
// Save the image to disk in JPEG format
bmp.Save(string.Format("Slide_{0}.jpg", sld.SlideNumber), System.Drawing.Imaging.ImageFormat.Jpeg);
}
}

PowerPoint Presentation

PowerPoint PPTX to JPG in C#

Converted JPG Images

PPT PPTX to JPG in C#

Convert PowerPoint PPTX to JPG with Customized Dimensions in C#

You may also customize the dimensions of the JPG images as per your requirements. The following code sample shows how to define ScaleX and ScaleY values while converting PPTX to JPG in C#.

using (Presentation pres = new Presentation("PowerPoint-Presentation.pptx"))
{
// Define dimensions
int desiredX = 1200;
int desiredY = 800;
// Get scaled values 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 JPEG format
bmp.Save(string.Format("Slide_{0}.jpg", sld.SlideNumber), System.Drawing.Imaging.ImageFormat.Jpeg);
}
}

Get a Free Temporary License for Aspose.Slides for .NET

You can get a free temporary license for Aspose.Slides for .NET to avoid the trial limitations.

Conclusion

In this article, you have learned how to convert PowerPoint PPT slides to JPG images in C#. Thus, you can easy generate the thumbnails for the PowerPoint presentations programmatically. Also, you can seamlessly create slideshow of the presentations in your applications.

See Also

Tip: You may want to check out Aspose free PowerPoint to JPG or PPTX to JPG converter.