Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active September 1, 2021 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/adf0d42992442cb65f4882048b80d343 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/adf0d42992442cb65f4882048b80d343 to your computer and use it in GitHub Desktop.
Convert PowerPoint to PNG using C#
// 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