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 pres = System::MakeObject<Presentation>(u"PowerPoint-Presentation.ppt");

for (auto&& sld : pres->get_Slides())
{
    // Creates a full scale image
    System::SharedPtr<System::Drawing::Bitmap> bmp = sld->GetThumbnail(1.0f, 1.0f);

    // Saves the image to disk in JPEG format
    bmp->Save(System::String::Format(u"Slide_{0}.jpg", sld->get_SlideNumber()),
              System::Drawing::Imaging::ImageFormat::get_Jpeg());
}

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::GetThumbnail() 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&& sld : pres->get_Slides())
{
    // Creates a full scale image
    System::SharedPtr<System::Drawing::Bitmap> bmp = sld->GetThumbnail(ScaleX, ScaleY);

    // Saves the image to disk in JPEG format
    bmp->Save(System::String::Format(u"Slide_{0}.jpg", sld->get_SlideNumber()),
              System::Drawing::Imaging::ImageFormat::get_Jpeg());
}

Render Comments when Saving Presentation into Image

Aspose.Slides for C++ provides a facility that allows you to render comments in a presentation’s slides when you are converting those slides into images. This C++ code demonstrates the operation:

// The path to the documents directory.
const String templatePath = u"../templates/TestDeck_050.pptx";
const String outPath = u"../out/RenderComments_out.png";

// Instantiates the Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);

// Creates a bitmap object
auto bmp = MakeObject<Bitmap>(740, 960);
SharedPtr<Graphics> graphics = Graphics::FromImage(bmp);

// Accesses the first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);

SharedPtr<NotesCommentsLayoutingOptions> opts = MakeObject<NotesCommentsLayoutingOptions>();
opts->set_CommentsAreaColor(Color::get_Red());

opts->set_CommentsAreaWidth(200);
opts->set_CommentsPosition(CommentsPositions::Right);
opts->set_NotesPosition(NotesPositions::BottomTruncated);

// Accesses and renders the first slide
pres->get_Slides()->idx_get(0)->RenderToGraphics(opts, graphics);
try
{
	bmp->Save(outPath, ImageFormat::get_Png());
}
catch (Exception e)
{
	System::Console::WriteLine(u"Exception " + e.get_Message());

}

See also

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