Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active October 15, 2021 14:58
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/3736d216e71030784785593601cc48fb to your computer and use it in GitHub Desktop.
Save aspose-com-gists/3736d216e71030784785593601cc48fb to your computer and use it in GitHub Desktop.
Add Slide Transitions in PowerPoint Presentations using C++
// File paths
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\\AddAdvancedTransition_out.pptx";
// Load the presentation file
auto presentation = System::MakeObject<Presentation>(sourceFilePath);
// Apply circle type transition on slide 1
presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Circle);
// Set the transition time of 3 seconds
presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_AdvanceOnClick(true);
presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_AdvanceAfterTime(3000);
// Apply comb type transition on slide 2
presentation->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Comb);
// Set the transition time of 5 seconds
presentation->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_AdvanceOnClick(true);
presentation->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_AdvanceAfterTime(5000);
// Save Presentation
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);
// File paths
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\\AddMorphTransition_out.pptx";
// Load the presentation file
auto presentation = System::MakeObject<Presentation>(sourceFilePath);
// Add morph transition
presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Morph);
auto morphTransition = System::DynamicCast<Aspose::Slides::SlideShow::IMorphTransition>(presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->get_Value());
morphTransition->set_MorphType(Aspose::Slides::SlideShow::TransitionMorphType::ByWord);
// Save Presentation
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);
// File paths
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\\AddTransition_out.pptx";
// Load the presentation file
auto presentation = System::MakeObject<Presentation>(sourceFilePath);
// Apply circle type transition on slide 1
presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Circle);
// Apply comb type transition on slide 2
presentation->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Comb);
// Save Presentation
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment