How to validate a PowerPoint PPTX Presentation in Python
1 min readAug 21, 2019
Validating PPTX files is very useful, so let’s make it simple, too. Two steps, let’s go.
Start by using pip install to add our API client:
pip install git+https://github.com/Cloudmersive/Cloudmersive.APIClient.Python.Convert.git
Then all that’s left is to call validate_document_pptx_validation and feed it your PPTX file.
from __future__ import print_function
import time
import cloudmersive_convert_api_client
from cloudmersive_convert_api_client.rest import ApiException
from pprint import pprint# Configure API key authorization: Apikey
configuration = 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 class
api_instance = cloudmersive_convert_api_client.ValidateDocumentApi(cloudmersive_convert_api_client.ApiClient(configuration))
input_file = '/path/to/file' # file | Input file to perform the operation on.try:
# Validate a PowerPoint presentation (PPTX)
api_response = api_instance.validate_document_pptx_validation(input_file)
pprint(api_response)
except ApiException as e:
print("Exception when calling ValidateDocumentApi->validate_document_pptx_validation: %s\n" % e)
That’s it! You’re done! Our API will provide you with the validity of the file as well as errors that make it invalid and possible warnings that could potentially interfere with the file’s usage.