DEV Community


Posted on


Add Transitions to Powerpoint Slides in Java

Slide transition in PowerPoint is the the visual effect that occurs when you move move from one slide to the next during a presentation. Adding transition between slides can be useful in helping audiences distinguish between different slides while keeping them engaged. This article will share how to programmatically add transitions to different presentation slides using Free Spire.Presentation for Java.

Import JAR Dependency (2 Methods)

● Download the free library and unzip it, and then add the Spire.Presentation.jar file to your project as dependency.
● Directly add the jar dependency to your maven project by adding the following configurations to the pom.xml.

Enter fullscreen mode Exit fullscreen mode

Sample Code

The Islide.getSlideShowTransition().setType() method, Islide.getSlideShowTransition().setSoundMode() method and Islide.getSlideShowTransition().setSpeed() method offered by Free Spire.Presentation for Java allow you to set transition type, sound mode and speed for the specified slides.
The complete sample code are as follows:

import com.spire.presentation.*;
import com.spire.presentation.drawing.transition.*;

public class setTransitions {
    public static void main(String[] args) throws Exception{

        //Load a PowertPoint document
        Presentation presentation = new Presentation();

        //Set the first slide transition as push and sound mode

        //Set the second slide transition as split and set the speed

        //Save the file
        presentation.saveToFile("setTransitions.pptx", FileFormat.PPTX_2010);
Enter fullscreen mode Exit fullscreen mode


Top comments (0)