How to Split PowerPoint PPT or PPTX Slides in Python

How to Split PowerPoint PPT or PPTX Slides in Python

PPTX is the default presentation file format for new PowerPoint presentations. Support for loading and saving PPT files is built into PPTX. PowerPoint files are also called presentations. Sometimes, you need to split a lengthy PowerPoint presentation into multiple files by slide range or extract all PowerPoint slides to multiple PPTX files. It will be time consuming task if you manually split a large PowerPoint files into presentations with original slides. In this article, we will demonstrate an easy solution about how to split PowerPoint PPT or PPTX slides in Python.

The following topics shall be covered in this article:

PowerPoint PPTX Splitter Cloud API and Python SDK

To split PowerPoint PPTX/PPT slides, I will be using the Python SDK of GroupDocs.Merger Cloud API. It allows you to rotate, split, join, remove and rearrange a single page or a collection of pages from supported document formats of Word, Excel, Visio drawings, PDF, and HTML. Python source code repository is freely available on the GitHub.

You can install PowerPoint splitter to your Python application with PIP from PyPI by using the following command in the terminal:

pip install groupdocs-merger-cloud

Please get your Client ID and Secret from the dashboard before following the below mentioned steps. Once you have your ID and Secret, add the below code into your application to split PowerPoint into two files as shown below:

How to Split PPTX to Several Single Slide Files in Python

You can split PowerPoint PPT/PPTX slides programmatically on the cloud by following the steps mentioned below.

Upload the Files

Firstly, we will upload the PowerPoint files to the cloud using the code example given below:

As a result, the uploaded files will be available in the files section of your dashboard on the cloud.

Split PowerPoint PPT/PPTX slides in Python

You can split pages of any PPTX file into separate PowerPoint slides programmatically by following the steps given below:

  • Firstly, create an instance of the DocumentApi.
  • Then, create an instance of the SplitOptions
  • Now, create an instance of the FileInfo
  • Pass input file path as argument to FileInfo
  • Next, provide output file path
  • Set specific page numbers in a comma separated array
  • Now, set pptx split mode to Pages. It allows to split page numbers in a comma separated array
  • Create SplitRequest with SplitOptions
  • Finally, call the DocumentAPI.split() method with SplitRequest as argument and get results

The following code snippet shows how to split PowerPoint file using REST API in Python:

PPTX Presentations in Python

Split PowerPoint PPT/PPTX Presentations in Python

Download the Separated File

Finally, the above code sample will save the separated file on the cloud using python. It can be downloaded using the following code sample:

Split PowerPoint to Single Slides by Pages Range in Python

You can split PowerPoint file pages by providing a range of page numbers programmatically by following the steps given below:

  • Create an instance of the DocumentApi
  • Then, create an instance of the SplitOptions
  • Now, create an instance of the FileInfo
  • Pass input file path as argument to FileInfo
  • Next, provide output file path as “python-testing”
  • Set start_page_number and end_page_number values
  • Set pptx split mode to Pages to split PowerPoint
  • Create SplitRequest with SplitOptions
  • Finally, call the DocumentAPI.split() method with SplitRequest as argument

The following code snippet shows how to split PowerPoint file by exact page numbers in Python using REST API:

Split PowerPoint PPTX to Several Single Slides by Applying Filter

You can separate PPTX slides by providing a range mode and filter programmatically by following the steps given below:

  • Create an instance of the DocumentApi
  • Then, create an instance of the SplitOptions
  • Now, create an instance of the FileInfo
  • Pass input file path as argument to FileInfo
  • Next, provide output file path as “python-testing”
  • Set start_page_number and end_page_number values
  • Next, set range_mode to “OddPages
  • Set pptx split mode to Pages to split PowerPoint
  • Create SplitRequest with SplitOptions
  • Finally, call the DocumentAPI.split() method with SplitRequest as argument

The following code snippet shows how to split slides file by applying filter using REST API in Python:

How to Split PowerPoint PPTX to Several Multi-Slides File in Python

You can split PowerPoint files into multipage PowerPoint slides programmatically by following the steps given below:

  • Create an instance of the DocumentApi
  • Then, create an instance of the SplitOptions
  • Now, create an instance of the FileInfo
  • Pass input file path as argument to FileInfo
  • Next, provide output file path as “python-testing”
  • Then, set pages collection in array format
  • Set pptx split mode to Intervals to split PowerPoint
  • Create SplitRequest with SplitOptions
  • Finally, call the DocumentAPI.split() method with SplitRequest as argument

The following code snippet shows how to split PowerPoint file into multi-page PowerPoint slides using REST API in Python:

Online Split PowerPoint File

How to split ppt slides online free? You can try our free online PowerPoint splitter to split PowerPoint document into multiple PPTX slides by a fixed number of pages or in various page ranges. Multiple pages PPTX documents are divided into multiple PPTX files keeping the format of the original document.

Conclusion

In this tutorial, we have learned:

  • how to split a PowerPoint presentation in Python on the cloud;
  • how to split PowerPoint slides into separate files in Python;
  • Programmatically how to split ppt slides by exact number in Python;
  • programmatically how to split ppt file by range mode in Python;

Additionally, you can learn more about GroupDocs.Merger Cloud API using the documentation. We also provide an API Reference section that lets you visualize and communicate with our APIs directly through the browser. Moreover, please see the GroupDocs.Merger Cloud SDK for Python Examples here.

Ask a question

If you have any questions about how to split ppt into multiple files online or to extract pages from ppt, please feel free to ask us on the Forum

See Also