Split PowerPoint Document into Individual Slides in Java

This article demonstrates how to split a PowerPoint document into multiple individual slides using Spire.Presentation for Java.

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();
        ppt.loadFromFile("C:\\Users\\Administrator\\Desktop\\sample.pptx");

        //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
            newppt.getSlides().removeAt(0);

            //Select a slide from the source file and append it to the new document
            newppt.getSlides().append(ppt.getSlides().get(i));

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

Output:

Split PowerPoint Document into Individual Slides in Java