[Python Study Notes] convert ppt to PDF in bulk v1,0

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.