在这个脚本中,ppt_to_pdf函数负责将一个PPTX文件转换为PDF文件,而convert_pptx_to_pdf_in_directory函数则负责遍历指定目录下的所有PPTX文件,并调用ppt_to_pdf函数进行转换。 请确保将directory_to_convert变量的值替换为你的PPTX文件所在的目录路径,然后运行这个脚本即可完成转换。
formatType)# formatType = 32 for ppt to pdfdeck.SaveAs(inputFileName.rsplit('.')[0]+'.jpg',17)deck.Close()defconvert_files_in_folder(powerpoint,folder):files=os.listdir(folder)pptfiles=[fforfinfilesiff.endswith((".ppt",".pptx"))]forpptfile...
='pdf':outputFileName=outputFileName+".pdf"deck=powerpoint.Presentations.Open(inputFileName)deck.SaveAs(outputFileName,formatType)# formatType=32forppt to pdf deck.Close()defconvert_files_in_folder(powerpoint,folder):files=os.listdir(folder)pptfiles=[fforfinfilesiff.endswith((".ppt",".pptx")...
print(f"PDF save to {pdfFile}") doc.close() 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. PDF转PPT 转PPT时需要用到pptx库:pip install python-pptx使用文档:https://python-pptx.readthedocs.io/en/latest/index.html 先把PDF转为图片,然后把每张图片生成一个幻灯片页面(PPT页面大小有width与heigh...
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) ...
exit() # 转换PDF文件为Word文档 converter = Converter(pdf_file_path) converter.convert(doc_...
deck.SaveAs(outputFileName, formatType)#formatType = 32 for ppt to pdfdeck.Close()defconvert_files_in_folder(powerpoint, folder): files=os.listdir(folder) pptfiles= [fforfinfilesiff.endswith((".ppt",".pptx"))]forpptfileinpptfiles: ...
outputFileName = outputFileName + ".pdf" deck = powerpoint.Presentations.Open(inputFileName) deck.SaveAs(outputFileName,formatType) deck.Close() def convert_files_in_folder(powerpoint,folder): files = os.listdir(folder) pptfiles = [f for f in files if f.endswith((".ppt",".pptx"))]...
convert(word_path+"/"+word_name, word_to_pdf+"/"+word_name.replace("docx","pdf")) 其中word_path是存放word文件的文件夹,word_to_pdf是转换后的pdf存放文件夹。 打开第一个pdf,内容如下: 可以看到文字、图片、以及排版***这些都与原文件(word)一模一样。 02...
pptfiles = [f for f in files if f.endswith((".ppt", ".pptx"))]for pptfile in pptfiles: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...