Learn how to convert PowerPoint presentations to PNG images in C#: https://blog.aspose.com/2021/09/01/convert-powerpoint-to-png-in-csharp/
Last active
September 1, 2021 15:18
-
-
Save aspose-com-gists/adf0d42992442cb65f4882048b80d343 to your computer and use it in GitHub Desktop.
Convert PowerPoint to PNG using C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load PowerPoint presentation | |
using (Presentation pres = new Presentation("presentation.pptx")) | |
{ | |
// User defined dimension | |
int desiredX = 1200; | |
int desiredY = 800; | |
// Getting scaled 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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment