[2024] How to Save PowerPoint as PDF and Vice Versa | Python

Casie LiuCasie Liu
4 min read

When sharing, and printing documents, it is commonly required to convert PowerPoint to PDF. PDF allows documents to contain a consistent format and layout across different platforms and devices. But if you are preparing a presentation, then what you need is to convert PDF to PowerPoint, which can enhance the attractiveness of your presentation.

In this article, we’ll guide you through how to save PowerPoint as PDF and back in Python, allowing you to leverage the efficiency of tasks. Let’s check it out!


Prepare for Tasks

To save a PowerPoint as a PDF in a programming way, we need Spire.Presentation for Python and Spire.PDF for Python. They are powerful Python libraries that support many features, such as format conversion, and that is what we will be going through later.

You can install Spire.Presentation for Python and Spire.PDF for Python from PyPI using the pip command below:

pip install Spire.Presentation

pip install Spire.PDF

How to Save PowerPoint as PDF: Specified Slides

When it comes to converting PowerPoint presentations to PDF, there are typically two scenarios: converting specific slides or converting the entire presentation into a multi-page PDF file. Sharing only the relevant slides can be more efficient and focused, especially when you need to present key information to clients or colleagues. In this section, we will first discuss how to save PDFs from PowerPoint slides, offering comprehensive steps and a code example.

Step to save PowerPoint as PDF in Python:

  • Create an object for the Presentation class.

  • Load a PowerPoint presentation to be converted from the disk with the Presentation.LoadFromFile() method.

  • Get a slide using the Presentation.Slides[] property.

  • Save the PowerPoint slide as a PDF by calling the Slide.SaveToFile() method and release resources.

Here is an example of saving the third slide as a PDF from PowerPoint:

from spire.presentation import *
from spire.presentation.common import *


# Create an object for the Presentation class
presentation = Presentation()

# Load a presentation file
presentation.LoadFromFile("input/presentation.pptx")

# Get the third slide of the presentation
slide = presentation.Slides[2]

# Save the slide as a PDF file
slide.SaveToFile("output/SlideToPDF.pdf", FileFormat.PDF)

# Release resources
presentation.Dispose()

Result of Saving Specified Slides as PDF

How to Save PowerPoint as PDF: Entire Presentation

The previous section mentioned that there are two common scenarios when converting PowerPoint presentations to PDF. We’ve already covered how to convert specific slides to PDF, so now let's move on to the second scenario: converting the entire presentation to PDF. This approach is particularly useful when you need to share comprehensive and detailed information about a project or need to print out a document. The PDF format effectively preserves the original layout of the presentation and also offers a certain level of security. Now, let's dive into how to save a PowerPoint presentation as a PDF.

Steps to save a PowerPoint as a PDF:

  • Create a Presentation object.

  • Open the PowerPoint presentation to be transformed using the Presentation.LoadFromFile() method.

  • Save the PowerPoint as a PDF by calling the Presentation.LoadFromFile() method.

  • Release resources.

Below is the code example of how to save a PowerPoint as a PDF in Python:

from spire.presentation import *
from spire.presentation.common import *


# Create an object for the Presentation class
presentation = Presentation()

# Load a presentation file
presentation.LoadFromFile("input/presentation.pptx")

# Save the slide as a PDF file
presentation.SaveToFile("output/PreToPDF.pdf", FileFormat.PDF)

# Release resources
presentation.Dispose()

Result of Converting PowerPoint Presentation to PDF

How to Convert PDF to PowerPoint in Python

When working with PowerPoint presentations, changing a PDF to a PowerPoint presentation can be highly beneficial. This process allows you to transform static content into a more engaging and interactive format, making your presentation more vivid and captivating. By doing so, you can better capture your audience's attention and enhance their understanding of the points and ideas being presented.

Steps to convert PDF to PowerPoint in Python:

  • Create a PdfDocument instance.

  • Open the PDF to be converted from the file path with the PdfDocument.LoadFromFile() method.

  • Save the PDF document as a PowerPoint file using the PdfDocument.SaveToFile() method.

  • Release the resources.

Here is a code example for converting PDF to Presentation

from spire.pdf.common import *
from spire.pdf import *


# Create an object of the PdfDocument class
pdf = PdfDocument()

# Load a sample PDF document
pdf.LoadFromFile("E:/Administrator/Python1/input/sample1.pdf")

# Save the PDF document as a PowerPoint PPTX file
pdf.SaveToFile("E:/Administrator/Python1/output/topptx.pptx", FileFormat.PPTX)

# Release resources
pdf.Close()

Showcase of Converting PDF as PPT

The Conclusion

This article introduces how to save PowerPoint as PDF in Python, including saving certain slides as PDF and converting an entire presentation to PDF. Moreover, the page explores changing PDF back to PowerPoint. Each section contains comprehensive instructions and a code example to help you easily perform these conversions. We hope you find it useful!

0
Subscribe to my newsletter

Read articles from Casie Liu directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Casie Liu
Casie Liu