DEV Community


Java/ Split PowerPoint Document into Individual Slides

jazzzzz profile image Jane ・1 min read

This article will introduce a time-saving method to split a PowerPoint document into multiple individual slides in Java application.

Tools Used:
● Free Spire.Presentation for Java
● IntelliJ IDEA

Method 1: Download the Free Spire.Presentation for Java and unzip it. Then add the Spire.Presentation.jar file to your project as dependency.

Method 2: You can also add the jar dependency to your maven project by adding the following configurations to the pom.xml.

Enter fullscreen mode Exit fullscreen mode

The test PowerPoint which contains 3 slides is shown as below:
Alt Text

Code Snippet

import com.spire.presentation.FileFormat;
import com.spire.presentation.Presentation;

public class SplitPowerPoint {

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

        //Load the sample PowerPoint file
        Presentation ppt = new Presentation();

        //Loop through the slides
        for (int i = 0; i < ppt.getSlides().getCount(); i++)
            //Create an instance of Presentation class
            Presentation newppt = new Presentation();

            //Remove the default slide

            //Select a slide from the source file and append it to the new document

            //Save to file
            newppt.saveToFile(String.format("output/result-%d.pptx",i), FileFormat.PPTX_2013);
Enter fullscreen mode Exit fullscreen mode

Alt Text

Discussion (0)

Editor guide