Cloudmersive

May 13, 2020

1 min read

How to convert a PowerPoint PPTX to Text TXT in Python

The typical process of converting a PPTX presentation into plain text is a long and boring one. That’s not really a problem, though, if you follow this quick tutorial. We will be skipping all of that hassle.

With pip install, add our Convert API Client:

pip install cloudmersive-convert-api-client

We can now write our function call for convert_document_pptx_to_txt. This will need to include an API instance, created with a key. Here is an example of how this might look:

from __future__ import print_functionimport timeimport cloudmersive_convert_api_clientfrom cloudmersive_convert_api_client.rest import ApiExceptionfrom pprint import pprint# Configure API key authorization: Apikeyconfiguration = cloudmersive_convert_api_client.Configuration()configuration.api_key['Apikey'] = 'YOUR_API_KEY'# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['Apikey'] = 'Bearer'# create an instance of the API classapi_instance = cloudmersive_convert_api_client.ConvertDocumentApi(cloudmersive_convert_api_client.ApiClient(configuration))input_file = '/path/to/file' # file | Input file to perform the operation on.try:# Convert PowerPoint PPTX Presentation to Text (txt)api_response = api_instance.convert_document_pptx_to_txt(input_file)pprint(api_response)except ApiException as e:print("Exception when calling ConvertDocumentApi->convert_document_pptx_to_txt: %s\n" % e)

And there you have our completed solution. All that’s left is to put in your request and you will have your results in no time.