Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active September 13, 2021 15: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/720ed0500e080500089dacbb25cb4e4e to your computer and use it in GitHub Desktop.
Save aspose-com-gists/720ed0500e080500089dacbb25cb4e4e to your computer and use it in GitHub Desktop.
Apply Animation Effects to Text in PowerPoint using Java
// Load presentation
Presentation presentation = new Presentation("Presentation.pptx");
try {
// Select paragraph to add effect
IAutoShape autoShape = (IAutoShape)presentation.getSlides().get_Item(0).getShapes().get_Item(0);
IParagraph paragraph = autoShape.getTextFrame().getParagraphs().get_Item(0);
// Add Fly animation effect to selected paragraph
IEffect effect = presentation.getSlides().get_Item(0).getTimeline().getMainSequence().
addEffect(paragraph, EffectType.Fly, EffectSubtype.Left, EffectTriggerType.OnClick);
// Save presentation
presentation.save("AnimationEffectinParagraph.pptx", SaveFormat.Pptx);
} finally {
if (presentation != null) presentation.dispose();
}
// Load presentation
Presentation presentation = new Presentation("Presentation.pptx");
try {
// Get sequence and shape from slide
ISequence sequence = pres.getSlides().get_Item(0).getTimeline().getMainSequence();
IAutoShape autoShape = (IAutoShape)pres.getSlides().get_Item(0).getShapes().get_Item(0);
// Loop through the paragraphs
for (IParagraph paragraph : autoShape.getTextFrame().getParagraphs())
{
// Access animation effects
IEffect[] effects = sequence.getEffectsByParagraph(paragraph);
if (effects.length > 0)
System.out.println("Paragraph \"" + paragraph.getText() + "\" has " + effects[0].getType() + " effect.");
}
} finally {
pres.dispose();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment