Convert Powerpoint PPT to JPG

Convert Presentation to Set of Images

In some cases, it is necessary to convert the entire presentation into a set of images, the same as PowerPoint allows. The C++ code shows you how to convert a presentation to JPG images:

auto imageScale = 1.0f;

auto pres = System::MakeObject<Presentation>(u"PowerPoint-Presentation.ppt");

for (auto&& slide : pres->get_Slides())
{
    // Creates a full scale image
    System::SharedPtr<IImage> image = slide->GetImage(imageScale, imageScale);

    // Saves the image to disk in JPEG format
    auto imageFileName = System::String::Format(u"Slide_{0}.jpg", slide->get_SlideNumber());
    image->Save(imageFileName, ImageFormat::Jpeg);

    image->Dispose();
}

pres->Dispose();

Convert PowerPoint PPT/PPTX to JPG with Customized Dimensions**

To change the dimension of the resulting thumbnail and JPG image, you can set the ScaleX and ScaleY values by passing them into float scaleX, float Y of the ISlide::GetImage() method:

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

// Defines dimensions
int32_t desiredX = 1200, desiredY = 800;

// Gets scaled values of X and Y
float scaleX = (float)(1.0 / pres->get_SlideSize()->get_Size().get_Width()) * desiredX;
float scaleY = (float)(1.0 / pres->get_SlideSize()->get_Size().get_Height()) * desiredY;

for (auto&& slide : pres->get_Slides())
{
    // Creates a full scale image
    System::SharedPtr<IImage> image = slide->GetImage(scaleX, scaleY);

    // Saves the image to disk in JPEG format
    auto imageFileName = System::String::Format(u"Slide_{0}.jpg", slide->get_SlideNumber());
    image->Save(imageFileName, ImageFormat::Jpeg);

    image->Dispose();
}

pres->Dispose();

See also

See other options to convert PPT/PPTX into image like: