How to convert PowerPoint PPTX to PDF in Python
1 min readAug 22, 2019
Using one of our handy APIs, converting PPTX to PDF is easy as pie. First use pip installer to add the convert client:
pip install git+https://github.com/Cloudmersive/Cloudmersive.APIClient.Python.Convert.git
Next we call the convert_document_autodetect_to_pdf function.
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.ConvertDocumentApi(cloudmersive_convert_api_client.ApiClient(configuration))
input_file = '/path/to/file' # file | Input file to perform the operation on.try:
# Convert Document to PDF
api_response = api_instance.convert_document_autodetect_to_pdf(input_file)
pprint(api_response)
except ApiException as e:
print("Exception when calling ConvertDocumentApi->convert_document_autodetect_to_pdf: %s\n" % e)
Boom! Done! Note that this function supports a wide variety of other file types and will recognize them automatically. These formats include XLSX, DOCX, PNG, JPG, and BMP.