Convert PowerPoint to PNG

About PowerPoint to PNG Conversion

The PNG (Portable Network Graphics) format is not as popular as JPEG (Joint Photographic Experts Group), but it still very popular.

Use case: When you have a complex image and size is not an issue, PNG is a better image format than JPEG.

Convert PowerPoint to PNG

Go through these steps:

  1. Instantiate the Presentation class.
  2. Get the slide object from the Presentation::get_Slides() collection under the ISlide interface.
  3. Use a ISlide::GetImage() method to get the thumbnail for each slide.
  4. Use the IImage::Save(String, ImageFormatPtr method to save the slide thumbnail to the PNG format.

This C++ code shows you how to convert a PowerPoint presentation to PNG:

auto pres = System::MakeObject<Presentation>(u"pres.pptx");
    
for (int32_t index = 0; index < pres->get_Slides()->get_Count(); index++)
{
    auto slide = pres->get_Slides()->idx_get(index);
    auto fileName = String::Format(u"slide_{0}.png", index);
    slide->GetImage()->Save(fileName, ImageFormat::Png);
}

Convert PowerPoint to PNG With Custom Dimensions

If you want to obtain PNG files around a certain scale, you can set the values for desiredX and desiredY, which determine the dimensions of the resulting thumbnail.

This code in C++ demonstrates the described operation:

auto pres = System::MakeObject<Presentation>(u"pres.pptx");

float scaleX = 2.f;
float scaleY = 2.f;
for (int32_t index = 0; index < pres->get_Slides()->get_Count(); index++)
{
    auto slide = pres->get_Slides()->idx_get(index);
    auto fileName = String::Format(u"slide_{0}.png", index);
    slide->GetImage(scaleX, scaleY)->Save(fileName, ImageFormat::Png);
}

Convert PowerPoint to PNG With Custom Size

If you want to obtain PNG files around a certain size, you can pass your preferred width and height arguments for ImageSize.

This code shows you how to convert a PowerPoint to PNG while specifying the size for the images:

auto pres = System::MakeObject<Presentation>(u"pres.pptx");
    
Size size(960, 720);
for (int32_t index = 0; index < pres->get_Slides()->get_Count(); index++)
{
    auto slide = pres->get_Slides()->idx_get(index);
    auto fileName = String::Format(u"slide_{0}.png", index);
    slide->GetImage(size)->Save(fileName, ImageFormat::Png);
}