News Category

How to Repeat an Animation in PowerPoint in Java

2020-03-25 08:28:47 Written by  support iceblue
Rate this item
(0 votes)

By default, an animation plays only one time and does not repeat. However, we can make the animation to play more than once by setting the repeat type of it. This article demonstrates how to accomplish this function using Spire.Presentation for Java.

import com.spire.presentation.*;
import com.spire.presentation.drawing.animation.AnimationEffect;

public class RepeatAnimation {
    public static void main(String[] args) throws Exception {
        //Create a Presentation instance
        Presentation ppt = new Presentation();
        //Load a PowerPoint document
        ppt.loadFromFile("Animation.pptx");
        
        //Get the first slide
        ISlide slide = ppt.getSlides().get(0);
        
        //Get the first animation effect on the slide
        AnimationEffect animation = slide.getTimeline().getMainSequence().get(0);
        //Set the animation effect to repeat forever until the end of slide.
        animation.getTiming().setAnimationRepeatType(AnimationRepeatType.UtilEndOfSlide);

        //Save the result document
        ppt.saveToFile("RepeatAnimation.pptx", FileFormat.PPTX_2013);
    }
}

Output:

How to Repeat an Animation in PowerPoint in Java

Additional Info

  • tutorial_title: Repeat an Animation in PowerPoint in Java
Last modified on Thursday, 02 September 2021 05:56