How to Split a PowerPoint Presentation into Separate Slides using Java

Splitting larger files into smaller & more manageable files is an easy way to reduce clutter and/or create quick spinoff projects. This is a particularly useful operation when it comes to PowerPoint slides, which are just as commonly used as sandbox templates for marketing materials as for their intended presentation purpose. Thankfully, there’s an API for that — our PowerPoint PPTX Split API will return a single file (or URL, if the optional ‘returnDocumentContents’ parameter is set to False) for each slide in a PPTX presentation. With a secure Cloudmersive API key (visit our website & register a free account to get one), you can take advantage of this API for free & structure your API call using Java code examples as demonstrated below.

We can begin installing the SDK with Maven by first adding a reference to the pom.xml repository:

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

And then adding a reference to the dependency:

<dependencies>
<dependency>
<groupId>com.github.Cloudmersive</groupId>
<artifactId>Cloudmersive.APIClient.Java</artifactId>
<version>v4.25</version>
</dependency>
</dependencies>

Next we can add the imports to the top of our file, configure the API key & input file parameters, and call the function:

// 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;
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");
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();
}

With that, you’re all set — you can easily split up PPTX presentations at scale.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cloudmersive

Cloudmersive

436 Followers

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.