
Split PowerPoint slides into separate files in Java
PowerPoint is among the widely used file format for data and information presentation. It is used for academic, official, governmental, etc purposes. However, the Presentation documents can be lengthy and you might not be interested to distribute the complete file. So we can split PowerPoint slides into separate files and distribute them accordingly. In this article, we are going to discuss the details of how we can programmatically split PPT files using Java SDK.
- PPT Conversion API
- Split PowerPoint Slides into Separate Files using Java
- Split PPT into Multiple Files using cURL Commands
PPT Conversion API
We are going to use Aspose.Slides Cloud SDK for Java to accomplish this requirement. The API enables you to create, manipulate as well as transform the PowerPoint slides into various supported formats. So in order to use the API, we need to add the following information in pom.xml of the maven build type project.
<repositories>
<repository>
<id>aspose-cloud</id>
<name>artifact.aspose-cloud-releases</name>
<url>http://artifact.aspose.cloud/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-slides-cloud</artifactId>
<version>22.4.0</version>
</dependency>
</dependencies>
Now in order to use the REST APIs, we also need to create a free account by visiting Aspose.Cloud dashboard. If you have GitHub or Google account, simply Sign Up and obtain your client credentials.
Split PowerPoint Slides into Separate Files using Java
Please follow the instructions given below to split the PowerPoint slides into separate files.
- Create an instance of SlidesApi while passing Client credentials as arguments
- Secondly, create an object of File and load the source PowerPoint file
- Convert PowerPoint content to Byte[] array using readAllBytes(…) method
- Now call the API method splitOnline(…) to split slides at indexes 2 and 3 to separate presentations
- Finally, print the path/location of the resultant .zip archive containing individual Presentations
Split PPT into Multiple Files using cURL Commands
We can also perform the PPT split operation using the cURL commands. However, we need to first generate the JWT access token according to client credentials. Please execute the following command to generate the JWT token.
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bbf94a2c-6d7e-4020-b4d2-b9809741374e&client_secret=1c9379bb7d701c26cc87e741a29987bb" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Now execute the following cURL command to split input PowerPoint from pages 2 to 3 and save them as separate documents.
curl -v -X POST "https://api.aspose.cloud/v3.0/slides/split/Ppt?from=2&to=3" \
-H "accept: multipart/form-data" \
-H "authorization: Bearer <JWT Token>" \
-H "Content-Type: multipart/form-data" \
-d {"document":{input.pptx}}
Conclusion
In this article, we have learned the details of how to Split PowerPoint Slides into separate files using Cloud SDK. We have specifically explored the details on how to programmatically split PPT using Java code snippets as well as how ppt split operation can be performed using the cURL Commands. Please note the complete source code of cloud SDK is available for download over GitHub and you can modify it as per your requirements. Furthermore, if you encounter any issues while using the SDK or you have any further queries, please feel free to contact us via the free product support forum.
Related Articles
We highly recommend visiting the following links to learn about: