I have been looking to convert a .pptx file to a .pdf file through a Python script for several hours but nothing seems to be working.
What I have tried:
I believe the answer has to be updated because because comtypes
doesn't work anymore.
So this is the code which works (updated version of the accepted answer) :
import win32com.client
def PPTtoPDF(inputFileName, outputFileName, formatType = 32):
powerpoint = win32com.client.DispatchEx("Powerpoint.Application")
powerpoint.Visible = 1
if outputFileName[-3:] != 'pdf':
outputFileName = outputFileName + ".pdf"
deck = powerpoint.Presentations.Open(inputFileName)
deck.SaveAs(outputFileName, formatType) # formatType = 32 for ppt to pdf
deck.Close()
powerpoint.Quit()