Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active September 23, 2021 17:08
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/0046740d3d811e40fa9a6566be50c906 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/0046740d3d811e40fa9a6566be50c906 to your computer and use it in GitHub Desktop.
Convert PowerPoint PPTX/PPT to PNG Images using C++
// Source file path
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx";
// Load the presentation file
auto presentation = System::MakeObject<Presentation>(sourceFilePath);
// User defined dimension
int desiredX = 1200;
int desiredY = 800;
// Getting scaled value of X and Y
float ScaleX = (float)(1.0 / presentation->get_SlideSize()->get_Size().get_Width()) * desiredX;
float ScaleY = (float)(1.0 / presentation->get_SlideSize()->get_Size().get_Height()) * desiredY;
// Loop through the slides
for (SharedPtr<ISlide> slide : presentation->get_Slides())
{
// Create image of the slide
SharedPtr<System::Drawing::Bitmap> bitmap = slide->GetThumbnail(ScaleX, ScaleY);
// Save the PNG file
bitmap->Save(String::Format(u"OutputDirectory\\PresentationToPng_out_{0}.png", slide->get_SlideNumber()), System::Drawing::Imaging::ImageFormat::get_Png());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment