[Python Study Notes] convert ppt to PDF in bulk

Source: Internet
Author: User

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

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.