DEV Community

Vijay Singh Khatri
Vijay Singh Khatri

Posted on

Convert PDF Files to PowerPoint PPT in Python

We often share and receive important business or personal documents in PDF format. PDF stands for Portable Document Format. It has become a standard format due to its cross-platform compatibility, i.e., it is independent of software, hardware, and operating systems.

The International Organisation for Standardisation (ISO) has made PDF the standard format. PDF files can contain different types of content, including images, text, links, audio, and video.

Many times, you may require to convert your PDF file into a different format, such as a PowerPoint presentation or Word.

Well, you can do it with your Python code if you are a programmer. Python allows us to convert PDF files seamlessly into PPT or PPTX formats.

We all know Python provides libraries to accomplish a variety of tasks. Among all tasks, one is to convert PDF files to PowerPoint PPT/PPTX.

In this article, I will help you write a Python program that converts any PDF file to a professional PowerPoint presentation. Before that, let me introduce you to the Python library we need to use for conversion.

Let us get started without any further ado!

*Aspose.Slides - The Python Library *

Aspose.Slides is a Python class library via .NET for processing PPT slides. It helps developers and applications read, modify, render, generate, print, and convert presentations without requiring third-party applications.

Furthermore, you do not need to install any third-party application to install Aspose.Slides.

Aspose.Slides for Python via .NET help you perform the following operations on presentations:

  • Load, open, view, and edit.
  • Convert them to PDF, GIF, Word, HTML, JPG, and other formats.
  • Render and print.
  • Encrypt and decrypt.
  • Manipulate entities, such as shapes, charts, pictures, frames, etc.

Using this library, we will take content from a PDF file and import it to PPT/PPTX file. Using the following command, you can install it from PyPI.

pip install aspose.slides
Enter fullscreen mode Exit fullscreen mode

Convert PDF Fies to PowerPoint PPT in Python

The Aspose.Slides for Python library takes care of importing data from a PDF file into a PPT slide. The conversion takes place as follows:

  • Specify the PDF file whose data you need to import into a presentation slide.
  • Create an empty slide.
  • Aspose.Slides will fetch the content from the specified PDF file and import it into the created slide.
  • Finally, save the slide.

Now, let us discuss the same steps in Python.

  • Use the Presentation class to create a new presentation of the PPT file.
  • With the Presentation.slides.remove_at(0) method, remove the default slide that comes added with that file.
  • Use the Presentation.slides.add_from_pdf(string) method to import PDF data into the file.
  • Finally, save the PPT file using the, SaveFormat) method. Save it as a PPT/PPTX file.

Python Code

import aspose.slides as slides
//create a new presentation
with slides.Presentation() as pres:

    //remove the default slide 

    //import PDF data to the slide

    //save the PPT file"file.pptx", slides.export.SaveFormat.PPTX)
Enter fullscreen mode Exit fullscreen mode

Converting the PPT Back to PDF

import aspose.slides as slides

# Instantiate an object that represents a PPT file
presentation = slides.Presentation("file.ppt")

# Save the PPT file as PDF"file.pdf", slides.export.SaveFormat.PDF)
Enter fullscreen mode Exit fullscreen mode

Here is another simple approach to converting PDF files to PowerPoint PPT in Python.


pdf2pptx is a Python package that renders each page as a PNG picture and generates a PPT from those images. Here is the command to do so:

pdf2pptx file.pdf
Enter fullscreen mode Exit fullscreen mode


This was all about converting PDF files to a PowerPoint presentation in Python. Though it may seem tricky in the beginning, Aspose.Slides for Python makes it pretty easy and quick. With just a few lines of Python code and methods, the conversion of PDF to PPT has become possible in a jiffy.

I hope you found this article helpful. If you have any queries, feel free to comment down below.

Top comments (0)