How to convert a PowerPoint PPTX to a PNG Array in Python

Cloudmersive
2 min readJun 13, 2020

--

Sometimes image files are just way more convenient than clunky Office formats like PPTX. For this type of situation, we require a means of conversion between formats. For all you Python users out there, this would normally require quite a lengthy foray into the coding jungle. But not today! No, today we will bust out an API to help us solve this particular problem (though it is capable of much more).

Let’s install the client for our API as our first step toward conversion salvation.

pip install cloudmersive-convert-api-client

Now let’s write our function call. Use this example as a model for how to work it into your project.

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 to PNG image arrayapi_response = api_instance.convert_document_pptx_to_png(input_file)pprint(api_response)except ApiException as e:print("Exception when calling ConvertDocumentApi->convert_document_pptx_to_png: %s\n" % e)

And, well, that’s all there is to that. Easy!

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet