Skip to content
Convert PowerPoint Slides to PDF in Bulk with a Simple Python Script
Fundamentals 2 min read

Convert PowerPoint Slides to PDF in Bulk with a Simple Python Script

This guide provides a Python script that automates the batch conversion of Microsoft PowerPoint files (.ppt or .pptx) to PDF, including setup steps, full source code, and instructions for running the script on a folder of presentations.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations

This Python script batch converts Microsoft PowerPoint files (.ppt or .pptx) to PDF format.

Usage Instructions

1. Place this script in the same folder as the PPT files. 2. Run the script.

Full Code

import comtypes.client
import os

def init_powerpoint():
    powerpoint = comtypes.client.CreateObject("Powerpoint.Application")
    powerpoint.Visible = 1
    return powerpoint

def ppt_to_pdf(powerpoint, inputFileName, outputFileName, formatType = 32):
    if outputFileName[-3:] != 'pdf':
        outputFileName = outputFileName + ".pdf"
    deck = powerpoint.Presentations.Open(inputFileName)
    deck.SaveAs(outputFileName, formatType) # formatType = 32 for ppt to pdf
    deck.Close()

def convert_files_in_folder(powerpoint, folder):
    files = os.listdir(folder)
    pptfiles = [f for f in files if f.endswith((".ppt", ".pptx"))]
    for pptfile in pptfiles:
        fullpath = os.path.join(cwd, pptfile)
        ppt_to_pdf(powerpoint, fullpath, fullpath)

if __name__ == "__main__":
    powerpoint = init_powerpoint()
    cwd = os.getcwd()
    convert_files_in_folder(powerpoint, cwd)
    powerpoint.Quit()
Project address: https://github.com/jackbrookes/batch-ppt-to-pdf/blob/master/batch_ppt_to_pdf.py
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Pythonbatch processingPDFPowerPoint
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.