Add Slide Transitions in PowerPoint Presentations using Java

Slide transitions are used to add visual effects, which occur while moving from one slide to another in a PowerPoint slideshow. You can also set transition sound, speed, duration, and other effects according to the context of your presentation. Accordingly, this article covers how to add slide transitions in PowerPoint presentations programmatically using Java.

Java API to Add Slide Transitions in PowerPoint

In order to add slide transitions in PPTX/PPT presentations, we will use Aspose.Slides for Java. The API allows creating and manipulating PowerPoint and OpenOffice presentations. You can either download the API’s JAR or install it using the following Maven configurations.

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>http://repository.aspose.com/repo/</url>
</repository>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-slides</artifactId>
    <version>21.8</version>
    <classifier>jdk16</classifier>
</dependency>

Add Slide Transition using Java

The following are the steps to add slide transition in a PowerPoint presentation using Java.

  1. First, load the PowerPoint presentation using Presentation class.
  2. Then, sset a slide transition type using SlideShowTransition.setType() method and TransitionType class.
  3. Finally, save the updated presentation using Presentation.save(String, SaveFormat) method.

The following code sample shows how to set the transition of a slide in a PowePoint presentation.

Add Advanced Slide Transitions using Java

The following are the steps to set advanced slide transition options such as duration, sound, speed, etc.

  1. First, load the PowerPoint presentation using Presentation class.
  2. Then, set a slide transition type using SlideShowTransition.setType() method and TransitionType class.
  3. Set a advanced effects such as Sound, AdvanceAfterTime, etc. (see list of effects).
  4. Finally, save the updated presentation using Presentation.save(String, SaveFormat) method.

The following code sample shows how to set advanced slide transition options in a PowerPoint presentation.

Set Morph Transition in PowerPoint using Java

Aspose.Slides for Java also allows setting the morph transitions, which are used to make smooth animations. The following morph transitions are supported by the API:

  • ByObject: Morph transition will be performed considering shapes as indivisible objects.
  • ByWord: Morph transition will be performed with transferring text by words where possible.
  • ByChar: Morph transition will be performed with transferring text by characters where possible.

The following are the steps to add morph transition in a PowerPoint presentation using Java.

  1. First, load the PowerPoint presentation using Presentation class.
  2. Then, set a slide transition type to TransitionType.Morph using SlideShowTransition.setType() method.
  3. Set morph transition type using IMorphTransition.setMorphType() method.
  4. Finally, save the updated presentation using Presentation.save(String, SaveFormat) method.

The following code sample shows how to set morph transitions in PowerPoint presentations.

Get a Free API License

You can use Aspose.Slides for Java without evaluation limitations by requesting a temporary license.

Conclusion

In this article, you have learned how to add slide transitions in PowerPoint presentations using Java. Moreover, you have seen how to set morph transitions in the PPTX/PPT presentations. Apart from this, you can visit the documentation to explore other features of API. Also, you can feel free to let us know about your queries via our forum.

See Also