Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active February 7, 2020 13:29
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/ea7de1097bd23deee0a6d59674d5f465 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/ea7de1097bd23deee0a6d59674d5f465 to your computer and use it in GitHub Desktop.
Convert PowerPoint to JPG in C# - Aspose.Slides for .NET
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);
}
}
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);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment