1. Products
  2.   Presentation
  3.   Python
  4.   Batch-PPT-to-PDF
 
  

PPT and PPTX Presentations Conversion to PDF via Python

An Easy to Use Open Source Python Script Designed to Convert Multiple Microsoft PowerPoint (.ppt and .pptx) Presentation Files to PDF Documents in One Go.

What is Batch-PPT-to-PDF?

Are you drowning in a sea of .pptx and .ppt files, manually converting them one by one to PDF? Whether you're a business professional archiving reports, a teacher distributing lecture notes, or a developer automating a workflow, this manual process is tedious and error-prone. The Batch-PPT-to-PDF script, created by Jack Brookes, offers an elegant Python-based solution that automates this entire process, saving professionals, educators, and businesses countless hours of manual work. There are several important features part of the library, such as processing multiple files simultaneously, cross-platform compatibility, converting selected slides to PDF, and so on.

Batch-PPT-to-PDF is a lightweight Python script designed to convert multiple Microsoft PowerPoint files (both .ppt and .pptx formats) to PDF documents in one go. This open-source tool leverages the power of Python's COM automation capabilities to interact directly with Microsoft PowerPoint installed on your Windows machine, ensuring high-fidelity conversions that preserve your original formatting, fonts, and layouts. The script requires minimal setup and no complex configuration files or command-line arguments, making it accessible even for users with limited programming experience. Its straightforward approach makes it accessible for beginners, while its scriptable nature makes it a powerful asset for developers and IT professionals.

Previous Next

Getting Started with Batch-PPT-to-PDF

The recommend way to install Batch-PPT-to-PDF Library is using GitHub. Please use the following command for a smooth installation.

Install PowerPoint to PDF Library via GitHub

 git clone https://github.com/jackbrookes/batch-ppt-to-pdf.git  
You can also download it directly from Aspose product release page.

Single PPT/PPTX Files Conversion to PDF via Python

The Batch-PPT-to-PDF script has included support for converting a single as well as multiple PowerPoint presentation files into PDF using Python library. Place the PowerPoint files you want to convert in the same folder as the script. The script will automatically detect and process all files with .ppt or .pptx extensions. The ppt_to_pdf() function handles the actual conversion of a single PowerPoint file. The function first checks if the output filename ends with 'pdf' extension. If not, it appends ".pdf" to ensure proper file naming. This safeguard prevents accidentally creating files without extensions. The following code example demonstrates how to perform Individual Presentation conversion to PDF inside Python apps.

How to Convert Individual PowerPoint Presentation to PDF via Python?

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)
    deck.Close()

Convert Bulk PowerPoint Files to PDF via Python

The open source Batch-PPT-to-PDF library makes it easy for software developers to load and convert multiple PowerPoint presentation files inside a single folder to PDF documents. Let’s suppose you have a folder on your Desktop, and you want to convert all PowerPoint files inside it to PDF, saving the results in a new folder somewhere on your disk. The following code example shows how to convert multiple PowerPoint presentations into PDF files using Python script.

How to Convert All PowerPoint Files in Folder to PDF inside Python Apps?

def convert_files_in_folder(powerpoint, folder):
    files = os.listdir(folder)
    pptFiles = [f for f in files if f.lower().endswith((".ppt", ".pptx"))]
    for pptfile in pptFiles:
        fullpath = os.path.join(folder, pptfile)
        outputpath = os.path.join(folder, os.path.splitext(pptfile)[0] + ".pdf")
        ppt_to_pdf(powerpoint, fullpath, outputpath)

High-Fidelity Output Support

Since the conversion is handled by the native Microsoft PowerPoint application itself, the resulting PDFs are of the highest quality. The script programmatically triggers PowerPoint's "Save As" function, ensuring that all fonts, images, shapes, and animations (exported as static slides) are preserved exactly as intended. You get a perfect PDF replica of your presentation, identical to what you would get by manually exporting it.