Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save groupdocs-cloud-gists/1654b12fa0021b841ff80b628e428fbe to your computer and use it in GitHub Desktop.
Save groupdocs-cloud-gists/1654b12fa0021b841ff80b628e428fbe to your computer and use it in GitHub Desktop.
Split PowerPoint PPT or PPTX Slides in Python

You can split PPTX slides programmatically on the cloud using Python Cloud REST API. In this article, you will learn how to split PowerPoint PPT/PPTX Slides using REST API in Python.

The following topics are covered in this article:

  1. PowerPoint PPTX Splitter Cloud API and Python SDK
  2. Split PPTX to Several Single Slide Files in Python
  3. Split PowerPoint to Single Slides by Pages Range in Python
  4. Split PowerPoint PPTX to Several Single Slides by Applying Filter
  5. Split PowerPoint PPTX to Several Multi-Slides File in Python
# API initialization to download merged file
import shutil
file_api = groupdocs_merger_cloud.FileApi.from_config(configuration)
# Create download file request
request = groupdocs_merger_cloud.DownloadFileRequest("python-testing\sample-powerpoint.pptx", storage_name)
# Download merged file
response = file_api.download_file(request)
# Move the downloaded file to your directory
shutil.move(response, "H:\\groupdocs-cloud-data\\")
# Upload PPTX file to cloud storage
# Create an instance of the file API
file_api = groupdocs_merger_cloud.FileApi.from_config(configuration)
# Call upload file request
request = groupdocs_merger_cloud.UploadFileRequest("python-testing\sample-powerpoint.pptx", "H:\\groupdocs-cloud-data\\sample-powerpoint.pptx", storage_name)
# Upload pptx file to the cloud
response = file_api.upload_file(request)
print(response.uploaded)
# How to Split PowerPoint PPTX to Several Multi-Slides File in Python
try:
# Create an instance of the Document API
documentApi = groupdocs_merger_cloud.DocumentApi.from_keys(app_sid, app_key)
options = groupdocs_merger_cloud.SplitOptions()
options.file_info = groupdocs_merger_cloud.FileInfo("python-testing\sample-powerpoint.pptx")
options.output_path = "python-testing"
options.pages = [3, 6, 8]
options.mode = "Intervals"
result = documentApi.split(groupdocs_merger_cloud.SplitRequest(options))
print("Successfully split PowerPoint to multiple slides: " + str(result))
except groupdocs_merger_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# How to Split PowerPoint PPTX into Several Single Slides by Applying Filter
try:
# Create an instance of the Document API
documentApi = groupdocs_merger_cloud.DocumentApi.from_keys(app_sid, app_key)
options = groupdocs_merger_cloud.SplitOptions()
options.file_info = groupdocs_merger_cloud.FileInfo("python-testing\sample-powerpoint.pptx")
options.output_path = "python-testing"
options.start_page_number = 3
options.end_page_number = 7
options.range_mode = "OddPages"
options.mode = "Pages" # options.mode = "Intervals"
result = documentApi.split(groupdocs_merger_cloud.SplitRequest(options))
print("Successfully split PPTX by range of slides using filter: " + str(result))
except groupdocs_merger_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# How to Split PowerPoint to Single Slides by Pages Range in Python
try:
# Create an instance of the Document API
documentApi = groupdocs_merger_cloud.DocumentApi.from_keys(app_sid, app_key)
options = groupdocs_merger_cloud.SplitOptions()
options.file_info = groupdocs_merger_cloud.FileInfo("python-testing\sample-powerpoint.pptx")
options.output_path = "python-testing"
options.start_page_number = 3
options.end_page_number = 5
options.mode = "Pages"
result = documentApi.split(groupdocs_merger_cloud.SplitRequest(options))
print("Successfully split powerpoint to single slides by slides range: " + str(result))
except groupdocs_merger_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# How to Split PPTX to Several Single Slide Files in Python
try:
# Create an instance of the Document API
documentApi = groupdocs_merger_cloud.DocumentApi.from_keys(app_sid, app_key)
options = groupdocs_merger_cloud.SplitOptions()
options.file_info = groupdocs_merger_cloud.FileInfo("python-testing\sample-powerpoint.pptx")
options.output_path = "python-testing"
options.pages = [1, 3]
options.mode = "Pages"
result = documentApi.split(groupdocs_merger_cloud.SplitRequest(options))
print("Successfully split powerpoint to single slides: " + str(result))
except groupdocs_merger_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# Import groupdocs merger SDK
import groupdocs_merger_cloud
# Get app_sid & app_key from https://dashboard.groupdocs.cloud after free registration.
app_sid = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
app_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Get File API configurations
configuration = groupdocs_merger_cloud.Configuration(app_sid, app_key)
configuration.api_base_url = "https://api.groupdocs.cloud"
storage_name = "LocalStorage"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment