Install and leverage cloud-based file format conversion, manipulation SDKs and REST APIs. Let’s learn how to combine PowerPoint files with a few lines of code.
Over the course of time, many documents are created by various people in organizations and for long-term archival purposes, they are combined together into a single unified source of information. Similarly, a document may contain too many details which cannot be shared with all the people, so as per requirement, the document can be split so that it can be shared accordingly. In this article, we are going to discuss, the details of how to merge PPT in Python.
- PPT processing SDK
- Installation
- Using cURL command to combine PowerPoint
- How to Merge PPT in Python
- Use the cURL command to Split PPT
- Split PPT in Python
Info: If you are looking to merge PowerPoint presentations online, you can use a free online tool like Aspose PowerPoint Merger. For combining or merging images, you may want to check out Aspose Collage Maker.
PPT processing SDK
Aspose.Slides Cloud is our award-winning REST API providing capabilities to the user to create, edit, process, and save major PowerPoint formats (including but not limited to PPTX, PPT, PPSX, PPTM, ODP, OTP, etc) to other popular file formats including TIFF, PDF, XPS, JPEG, HTML, etc. For more information, please visit Supported Document Formats. Furthermore, it enables you to perform a variety of other operations and their details can be found in the Overview.
In order to facilitate our customers specifically using Python programming language, we have created Aspose.Slides Cloud SDK for Python which is a wrapper around Aspose.Slides Cloud, so you get all the capabilities of Cloud API within your Python code.
Installation
In order to combine PowerPoint files using the Cloud SDK, the first step is to install it on your system. The SDK is available for download on PIP and GitHub. Please run the following command to perform the installation from pip
pip install asposeslidescloud
Another approach is to add dependencies directly in IDE when using PyCharm. Please search asposeslidescloud on Python Interpreter window under PyCharm -> Preferences… section.
Account Subscription
In this section of the blog post which is about how to merge PPT in Python, we are going to look over account subscriptions. We care about our customers and give vital importance to data integrity. Therefore, only authorized users can access the APIs as well as the documents available in their cloud storage. Therefore, the first step to enabling the PPT merger Python library is to create an account by visiting Aspose.Cloud dashboard. If you have GitHub or Google account, simply Sign Up. Otherwise, click on the Create a new Account button and provide the required information. Now login to the dashboard using credentials and expand the Applications section from the dashboard and scroll down towards the Client Credentials section to see Client ID and Client Secret details.
Using cURL command to combine PowerPoint
Aspose.Slides REST API can easily be accessed via cURL commands over the terminal. So in order to access the API using the cURL command, we need to first generate JSON Web Token (JWT) based on your ClientID and ClientSecret details retrieved from Aspose.Cloud dashboard. In order to set up this PowerPoint merger Please execute the following command in the terminal to generate the JWT token.
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=718e4235-8866-4ebe-bff4-f5a14a4b6466&client_secret=388e864b819d8b067a8b1cb625a2ea8e" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Once the JWT token has been generated, please use the following command to merge PPT files already available on Cloud storage. The filename provided against the PresentationPaths parameter will be merged to the source PPT file. For merge purposes, we are using PostPresentationMerge API. In the example below, output.ppt is the input PowerPoint document and Presentation1.ppt is the file to be merged.
curl -X POST "https://api.aspose.cloud/v3.0/slides/output.ppt/merge" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>" \
-H "Content-Type: application/json" \
-d "{ \"PresentationPaths\": [ \"Presentation1.ppt\" ]}"
How to merge PPT in Python
The following code snippets are of the PPT merger Python library explain the steps and details for merging two or more PPT files and generating a single concatenated file.
- The first step is to create a Configuration object
- Secondly, set the Client ID value to app_sid property and Client Secret details to app_key property
- In the next step, initialize the SlidesApi object while passing the Configuration instance as an argument
- Now create an object of the PresentationsMergeRequest object while passing the names of the Presentations file to be merged. The files are merged in the sequence the names are passed
- The next step is to call PostPresentationmergeRequest method which takes input PPT, and list of PPT files to be merged (as specified in the last code line)
- Finally, call the post_presentation_merge method of SlidesApi request
Use the cURL command to Split PPT
We can also split the PPT file into individual PowerPoint presentations using the cURL command. Please execute the following command to accomplish this requirement.
curl -X POST "https://api.aspose.cloud/v3.0/slides/test-unprotected.ppt/split?format=Pptx&from=2&to=3" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>" \
-H "Content-Type: application/json" \
-d "{ \"Format\": \"pptx\"}"
The sample PPT used in the above example can be downloaded from test-unprotected.ppt.
Split PPT in Python
The following code snippet explains the steps on how to split individual slides of PowerPoint as separate presentation files.
- First of all, create a Configuration object
- Secondly, set the Client ID value to app_sid property and Client Secret details to app_key property
- In the next step, initialize the SlidesApi object while passing the Configuration instance as an argument
- Penultimate, create an object of PostSlidesSplitRequest API which takes input PPT, output format value, From and To slide number against which the split operation will be performed
- Finally, call the post_slides_split(..) method and pass the PostSlidesSplitRequest object created above as an argument to initiate the PPT split operation
In case you need to save the split output in other formats, simply provide a related argument to PostSlidesSplitRequest object. The possible value can be from the list shown below
Conclusion
In this article, we have discussed the steps on how to merge PPT files into a single combined document and also, how to split individual slides of PowerPoint into separate PPT files. We have also gone through how to combine PowerPoint using the cURL command. The Cloud API of this PowerPoint merger can also be tested using a swagger interface within a web browser. Also, please note the complete source code of Aspose.Slides Cloud SDK for Python is open-source and can be downloaded from GitHub.
Should you have any related queries about this PPT merger Python library, please feel free to contact us via the free customer support forum.
Related Links
In order to read more about the exciting features being offered by Aspose.Slides Cloud API, we recommend visiting the following links