Script uses:
1.python 3.x (2.x not tested)
2. PowerPoint is required on the machine
3.pip Install ComTypes
4. Place the PPT,PPTX format file that needs to be transferred to the current directory
5. Run the script to wait
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "", "" "". "" "" "" "" "" "" "" "," "" "" "," "" "" "," "" "," "" ">> Ppt2pdf.py>> Author: Liu Yang>> e-mail: [email protected]>> blog: Www.cnblogs.com/liu66blog "" " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "." "" "" "" "" "" "" "" "" "" "" "" "" "#!/usr/bin/env python#-*-." Coding:utf-8-*-import sys, osimport comtypes.clientdef init_powerpoint (): PowerPoint = Comtypes.client.CreateObject (" PowerPoint.Application ") PowerPoint. Visible = 1 return powerpointdef ppt_to_pdf (PowerPoint, InputFileName, outputfilename, formattype = +): If Outputfi Lename[-3:]! = ' pdf ': outputfilename = OutputFileName + ". pdf" Deck = PowerPoint. Presentations.Open (InputFileName) deck. SaveAs (OutputFileName, formattype) # formattype = + 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 inPptfiles: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 () # Thanks to GitHub's original author # The script originated from https://github.com/jackbrookes/batch-ppt-to-pdf/blob/master/batch_ppt_to_pdf.py
[Python Study Notes] convert ppt to PDF in bulk