How to Split a Single PPTX Presentation into Separate Slides using Python

Cloudmersive
2 min readJul 22, 2022

Regular document processing operations for any size business typically entail a multitude of file conversions, size adjustments and fixed content replacements. Thankfully, our Document Conversion API endpoint offers dozens of solutions to expedite those operations significantly. In this article, we’ll demonstrate how you can take advantage of our PPTX Split API, which converts each slide within a PPTX document into its own individual file (or URL, depending on how you customize the returnDocumentContents parameter). The following demo will help you structure your API call using Python, and you can find additional code examples available in 12+ other programming languages on the Cloudmersive API console.

Our first step is to install the Python SDK with the following command:

pip install cloudmersive-convert-api-client

Next, let’s include the imports:

from __future__ import print_function
import time
import cloudmersive_convert_api_client
from cloudmersive_convert_api_client.rest import ApiException
from pprint import pprint

After that, let’s include the API key authorization snippet (you can get a key by registering a free account on our website) and call the function:

# Configure API key authorization: Apikey
configuration = cloudmersive_convert_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'
# create an instance of the API class
api_instance = cloudmersive_convert_api_client.SplitDocumentApi(cloudmersive_convert_api_client.ApiClient(configuration))
input_file = '/path/to/inputfile' # file | Input file to perform the operation on.
return_document_contents = true # bool | 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. (optional)
try:
# Split a single PowerPoint Presentation PPTX into Separate Slides
api_response = api_instance.split_document_pptx(input_file, return_document_contents=return_document_contents)
pprint(api_response)
except ApiException as e:
print("Exception when calling SplitDocumentApi->split_document_pptx: %s\n" % e)

After that, we’re all done — no code left to include.

--

--

Cloudmersive

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