Tag:pad point Skip too script rip htm ret getcwd
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "", "" "". "" "" "" "" "" "" "" "," "" "" "," "" "" "," "" "," "" ">> Ppt2pdf.py>> Author: Liu Yang>> e-mail: [email protected]>> blog: Www.cnblogs.com/liu66blog "" " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "." "" "" "" "" "" "" "" "" "" "" "" "" "#!/usr/bin/env python#-*-." Coding:utf-8-*-import sys, os# call COM component Package Import comtypes.client# First step: Get Ptrdef Init_powerpoint (): PowerPoint = ComTypes. Client. CreateObject ("PowerPoint.Application") Powerpoint. Visible = 1 return powerpoint# Second step: Locate all PPT (x) files under the path and add their paths to Cwddef Convert_files_in_folder (PowerPoint, folder): # will All current files and folders are added to the list file = Os.listdir (folder) print (' Files: ', files) # Add all files ending in. ppt (x) to CWD path pptfiles = [f fo R f in Files if F.endswith ((". ppt", ". pptx")])] [Pptfile in PPTFiles: # added to determine if the current converted PDF already exists, skip adding prin T (pptfile) if Pptfile+ '. pdf ' in Files:break # add CWD Environment FullPath = Os.path.join (CWD, Pptfile) Ppt_to_pdf (PowerPoint, FullPath, FullPath) #第三步: Convert CWD path to PDF format def ppt_to_pdf (PowerPoint, InputFileName, OutputFileName, formattype = 32): # The slicer suffix is pdf if outputfilename[-3:]! = ' pdf ': OutputFileName = OutputFile Name + ". pdf" # Call the interface to convert deck = PowerPoint. Presentations.Open (InputFileName) deck. SaveAs (OutputFileName, formattype) # formattype = + for ppt to PDF deck. Close () if __name__ = = "__main__": # get PowerPoint app ptr PowerPoint = Init_powerpoint () # Print (PowerPoint) # get Current Path CWD = OS.GETCWD () # Prints the current path print (CWD) # call Powerpoit to convert CWD path under the PPT (x) format Convert_files_in_folder (powe Rpoint, CWD) # Turn off PowerPoint after the conversion is complete. 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 v1,0 in bulk