Python里ppt转换pdf如何实现,方法是什么
这篇文章主要介绍了Python里ppt转换pdf如何实现,方法是什么相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇Python里ppt转换pdf如何实现,方法是什么文章都会有所收获,下面我们一起来看看吧。
上述内容具有一定的借鉴价值,感兴趣的朋友可以参考,希望能对大家有帮助,想要了解更多"Python里ppt转换pdf如何实现,方法是什么"的内容,大家可以关注博信的其它相关文章。
这是一个Python脚本,能够批量地将微软Powerpoint文件(.ppt或者.pptx)转换为pdf格式。
使用说明
1、将这个脚本跟PPT文件放置在同一个文件夹下。
2、运行这个脚本。
全部代码
importcomtypes.client importos definit_powerpoint(): powerpoint=comtypes.client.CreateObject("Powerpoint.Application") powerpoint.Visible=1 returnpowerpoint defppt_to_pdf(powerpoint,inputFileName,outputFileName,formatType=32): ifoutputFileName[-3:]!='pdf': outputFileName=outputFileName+".pdf" deck=powerpoint.Presentations.Open(inputFileName) deck.SaveAs(outputFileName,formatType)#formatType=32forppttopdf deck.Close() defconvert_files_in_folder(powerpoint,folder): files=os.listdir(folder) pptfiles=[fforfinfilesiff.endswith((".ppt",".pptx"))] forpptfileinpptfiles: fullpath=os.path.join(folder,pptfile) ppt_to_pdf(powerpoint,fullpath,fullpath) if__name__=="__main__": powerpoint=init_powerpoint() cwd=os.getcwd() convert_files_in_folder(powerpoint,cwd) powerpoint.Quit()
上述内容具有一定的借鉴价值,感兴趣的朋友可以参考,希望能对大家有帮助,想要了解更多"Python里ppt转换pdf如何实现,方法是什么"的内容,大家可以关注博信的其它相关文章。
版权声明
本文仅代表作者观点,不代表博信信息网立场。