Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active October 4, 2021 10:39
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/92acf66108007302f1a992adc9ae9137 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/92acf66108007302f1a992adc9ae9137 to your computer and use it in GitHub Desktop.
Apply Animation to Text in PowerPoint using C++
// File paths
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation2.pptx";
const String outputFilePath = u"OutputDirectory\\ApplyTextAnimation.pptx";
// Load the Presentation file
SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath);
// Access the shape
SharedPtr<IAutoShape> autoShape = System::DynamicCast_noexcept<Aspose::Slides::IAutoShape>(presentation->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0));
// Access the paragraph
auto paragraph = autoShape->get_TextFrame()->get_Paragraphs()->idx_get(0);
// Add the effect
auto effect = presentation->get_Slides()->idx_get(0)->get_Timeline()->get_MainSequence()->AddEffect(paragraph, EffectType::Fly, EffectSubtype::Left, EffectTriggerType::OnClick);
// Save Presentation file
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);
// File path
const String sourceFilePath = u"OutputDirectory\\ApplyTextAnimation.pptx";
// Load the Presentation file
SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath);
// Get the sequence
auto sequence = presentation->get_Slides()->idx_get(0)->get_Timeline()->get_MainSequence();
// Access the shape
SharedPtr<IAutoShape> autoShape = System::DynamicCast_noexcept<Aspose::Slides::IAutoShape>(presentation->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0));
// Loop through the paragraphs
for (SharedPtr<IParagraph> paragraph : autoShape->get_TextFrame()->get_Paragraphs())
{
// Get the effects
auto effects = sequence->GetEffectsByParagraph(paragraph);
if (effects->get_Length() > 0)
{
// Print to the console
Console::WriteLine(String::Format(u"Paragraph {0} has {1} effect.", paragraph->get_Text(), effects->idx_get(0)->get_Type()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment