How to Split PowerPoint PPTX Files into Separate Slides in Java
Learn how to split PowerPoint documents using just a few lines of code.

Like many multi-page assembly documents, PowerPoint PPTX files are often composed of slides that simultaneously work cohesively in a presentation and stand alone with their own independent value. Dividing these presentations into individual slides makes each separate piece of the presentation more easily accessible to a relevant audience, and it removes the need to share or download entire large PowerPoint documents.
In this tutorial, we’ll learn how to call a free API that automatically splits up PowerPoint documents into an array of individual slides. This will create an automated, efficient, and scalable processing pipeline for our PowerPoint documents, enabling us to extract and distribute slides for a variety of different purposes.
Step 1: Install the Maven SDK
First things first, we’re going to add the following reference to the repository in our pom.xml:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>Next, we’re going to add a reference to the dependency in our pom.xml:
<dependencies>
<dependency>
<groupId>com.github.Cloudmersive</groupId>
<artifactId>Cloudmersive.APIClient.Java</artifactId>
<version>v4.25</version>
</dependency>
</dependencies>Step 2: Add the Import Classes
With our SDK installed, we’re now going to add the below import classes to the top of our file:
// Import classes:
//import com.cloudmersive.client.invoker.ApiClient;
//import com.cloudmersive.client.invoker.ApiException;
//import com.cloudmersive.client.invoker.Configuration;
//import com.cloudmersive.client.invoker.auth.*;
//import com.cloudmersive.client.SplitDocumentApi;Step 3: Configure an API Key
If we haven’t used Cloudmersive APIs in the past, we’ll need to head to the Cloudmersive website, set up a free account, and copy our free API key to our clipboard before we complete this step. That’s how we’ll authorize our API calls; with a free API key, we’ll get a limit of 800 API calls per month with zero commitments.
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");
Apikey.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//Apikey.setApiKeyPrefix("Token");Step 4: Instance the API & Process our PPTX File
In our final step, we’ll create our instance of the SplitDocumentApi, provide our file path, and set the returnDocumentContents Boolean to determine if we should return slide URLs AND slide contents or URLs only. If we only want URLs (sometimes more efficient for larger PPTX files), we can set this variable to false.
SplitDocumentApi apiInstance = new SplitDocumentApi();
File inputFile = new File("/path/to/inputfile"); // File | Input file to perform the operation on.
Boolean returnDocumentContents = true; // Boolean | Set to true to return the contents of each presentation directly, set to false to only return URLs to each resulting presentation. Default is true.
try {
SplitPptxPresentationResult result = apiInstance.splitDocumentPptx(inputFile, returnDocumentContents);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling SplitDocumentApi#splitDocumentPptx");
e.printStackTrace();
}Our try-catch statement will either print our response object or relevant, detailed error messages to the console.
And that’s all there is to it! Now we can easily automate the process of splitting up our PowerPoint PPTX presentations into separate slides.


