How to Convert PowerPoint to PDF using REST API in Python

How to Convert PowerPoint to PDF using REST API in Python
How to Convert PowerPoint to PDF using REST API in Python

A PowerPoint presentation file is a collection of slides where each ppt/pptx slide can contain information like text, images, formatting, animations, and other media. While a PDF file format can comprise of text, images, hyperlinks, form-fields, rich media, attachments, and digital signatures etc. As a Python developer, you can make PPT and PPTX slides easy to view by converting to PDF files for Windows & MAC. In this article, we will learn how to convert PowerPoint to PDF using REST API in Python.

The following topics shall be covered in this article:

PowerPoint to PDF Conversion REST API – Installation

For converting PPTX slides to PDF, we will be using the Python SDK of GroupDocs.Conversion Cloud API. It is a platform independent documents and images conversion solution. It allows you to quickly and reliably convert images and documents of any supported file format to any format you need.

You can install GroupDocs.Conversion Cloud to your Python application using the following command in the console:

pip install groupdocs_conversion_cloud

Please get your Client ID and Secret from the dashboard before following the mentioned steps. Once you have your ID and secret, add in the code as shown below:

Convert PowerPoint PPTX to PDF using REST API in Python

You can convert your powerpoint slides to PDF programmatically on the cloud by following the simple steps given below:

  1. Upload the PPTX slides to the cloud
  2. Convert PowerPoint to PDF using Python
  3. Download the converted PDF file

Upload the PPTX File

Firstly, upload the pptx file to the cloud using the following code sample:

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

Convert PowerPoint to PDF using Python

You can easily convert powerpoint ppt/pptx to PDF file programmatically by following the steps mentioned below:

  • Firstly, create an instance of the ConvertApi
  • Now, create an instance of the ConvertSettings
  • Then, provide the input pptx file path
  • Set output file format as the “pdf”
  • Next, provide the output file path
  • Now, create ConvertDocumentRequest with ConvertSettings
  • Finally, convert pptx file by calling the convert_document() method with ConvertDocumentRequest.

The following code example shows how to convert PPTX to PDF using REST API in Python:

How to Convert PowerPoint to PDF using REST API in Python
How to Convert PowerPoint to PDF using REST API in Python

Download the Converted File

The above code sample will save the converted PDF file on the cloud. You can download it using the following code sample:

Convert Range of Pages from PPTX to PDF in Python

We can convert a range of pages from PPTX presentations to PDF documents programmatically by following the steps given below:

  • Firstly, create an instance of the ConvertApi.
  • Next, create an instance of the ConvertSettings.
  • Then, set the input PDF file path.
  • And, assign “pptx” to format.
  • Also, provide the output file path.
  • Next, create an instance of the PdfConvertOptions.
  • Then, set a page range to convert from start page number as fromPage and total pages to convert as pagesCount.
  • After that, create ConvertDocumentRequest with ConvertSettings as argument.
  • Finally, call the ConvertApi.convertDocument() method with ConvertDocumentRequest.

The following code example shows how to convert a range of pages from PDF to PPTX using a REST API in Python:

Convert Specific Pages of PPTX to PDF in Python

We can convert specific pages of PPTX slides to PDF documents programmatically by following the steps given below:

  • Firstly, create an instance of the ConvertApi.
  • Next, create an instance of the ConvertSettings.
  • Then, set the input PDF file path.
  • And, assign “pptx” to format.
  • Also, provide the output file path.
  • Next, create an instance of the PdfConvertOptions.
  • Then, provide specific page numbers in a comma-separated array to convert.
  • After that, create ConvertDocumentRequest with ConvertSettings as argument.
  • Finally, call the ConvertApi.convertDocument() method with ConvertDocumentRequest.

The following code example shows how to convert specific pages from PPTX to PDF using a REST API in Python:

Convert PPTX to PDF – Online and Free

How to convert ppt to pdf online free? Please try the following free online PPTX conversion tool from any device with a modern browser like Chrome and Firefox. It has been developed using the Groupdocs.Conversion API.

Conclusion

In this article, we have learned:

  • how to convert PowerPoint presentation to PDF on the cloud;
  • how to programmatically upload a PPTX file to the cloud;
  • how to download the converted PDF file from the cloud;
  • how to convert specific pages from PPTX to PDF in Python;
  • how to a range of pages from PPTX to PDF in Python;

Moreover, you can learn more about GroupDocs.Conversion Cloud API using the documentation. We also provide an API Reference section that lets you visualize and interact with our APIs directly through the browser.

Ask a question

If you have any questions about PowerPoint PPT/PPTX to DOCX Converter, please feel free to ask in GroupDocs.Conversion Forum and it will be answered within a few hours.

See Also