Giter VIP home page Giter VIP logo

batch-ppt-to-pdf's Introduction

batch-ppt-to-pdf

Python script to convert a bunch of Microsoft Powerpoint files (.ppt or .pptx) to PDF. Powerpoint must be installed on the machine for this to work.

Instructions for usage

  1. Put this script in the same folder as some powerpoint files
  2. Run the script
python batch_ppt_to_pdf.py 

Tested with Python 3 on Windows

batch-ppt-to-pdf's People

Contributors

jackbrookes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

batch-ppt-to-pdf's Issues

AttributeError

When I run your code, I meet an error:

Traceback (most recent call last):
  File "convert.py", line 24, in <module>
    powerpoint = init_powerpoint()
  File "convert.py", line 5, in init_powerpoint
    powerpoint = comtypes.client.CreateObject("Powerpoint.Application")
  File "D:\software\Anaconda\envs\MCM\lib\site-packages\comtypes\client\__init__.py", line 250, in CreateObject
    return _manage(obj, clsid, interface=interface)
  File "D:\software\Anaconda\envs\MCM\lib\site-packages\comtypes\client\__init__.py", line 188, in _manage
    obj = GetBestInterface(obj)
  File "D:\software\Anaconda\envs\MCM\lib\site-packages\comtypes\client\__init__.py", line 112, in GetBestInterface
    interface = getattr(mod, itf_name)
AttributeError: module 'comtypes.gen.PowerPoint' has no attribute '_Application'

The solution to this problem is change the method init_powerpoint to:

def init_powerpoint():
    powerpoint = win32com.client.DispatchEx("Powerpoint.Application")
    return powerpoint

'Powerpoint.Application' is invalid class string

20180704105942

Python version: 3.6.5 ,the error message '无效的类字符串' means 'invalid class string', my pc does not install Microsoft office.I use LibreOffice, does this reason cause the error?

suggestion

  • provide the required library of the script. Like: "lock" file
  • the resulted file end with ".pdf", not ".pptx.pdf" or ".pptx.pdf"

that is all, thank you :)

Probably will not work if the PowerPoints are not in the current working directory?

Shouldn't the second last line in the below be

fullpath = os.path.join(folder, pptfile)

not cwd?

def convert_files_in_folder(powerpoint, folder):
    files = os.listdir(folder)
    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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.