-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathppexport.py
34 lines (26 loc) · 1.09 KB
/
ppexport.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from gooey import Gooey
from gooey import GooeyParser
import argparse
import os
import comtypes.client
def export_presentation(ppt, outdir, width, height):
powerpoint = comtypes.client.CreateObject("Powerpoint.Application")
powerpoint.Visible = True
powerpoint.Presentations.Open(ppt)
powerpoint.ActivePresentation.Export(outdir, "JPG", int(width), int(height))
powerpoint.Presentations[1].Close()
powerpoint.Quit()
@Gooey
def main():
parser = GooeyParser(description="PowerPoint Exporter")
parser.add_argument('powerpoint', widget="FileChooser")
parser.add_argument('output', help="Folder to place resulting images", widget="DirChooser")
parser.add_argument('width', help="Width of resulting image (0-3072)")
parser.add_argument('height', help="Height of resulting image (0-3072)")
args = parser.parse_args()
if not (os.path.isfile(args.powerpoint) and os.path.isdir(args.output)):
raise "Invalid paths!"
export_presentation(args.powerpoint, args.output, args.width, args.height)
print "Done!"
if __name__ == "__main__":
main()