SoFunction
Updated on 2024-11-14

Batch convert ppt to pdf Python code Just 27 lines!

This is a Python script to batch convert Microsoft Powerpoint files (.ppt or .pptx) to pdf format.

Instructions for use

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

All Codes

import 
import os

def init_powerpoint():
 powerpoint = ("")
  = 1
 return powerpoint

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

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

if __name__ == "__main__":
 powerpoint = init_powerpoint()
 cwd = ()
 convert_files_in_folder(powerpoint, cwd)
 ()

source code address

This is the whole content of this article.