2
votes

I've been using python-pptx to access slides (I find it much smoother than using win32 as it doesn't need to open the Powerpoint window. However, I've checked the docs but can't find any method of printing a slide. Am I missing something?

Here is what I have so far:

from pptx import Presentation
prs = Presentation(path)
for slide in prs.slides:
    if slide.name == slide_I_want:
        #send slide to printer
1

1 Answers

2
votes

python-pptx (purposely) does not have a PowerPoint renderer, and so cannot print slides (render them to paper/PDF). It also can't save as PDF, save as JPG, or do anything else that requires rendering (such as automatically shrink text to fit into a particular region).

The rationale is basically one of scope and focus. A renderer is a complex piece of software all on its own, and is only weakly coupled to a (headless) PPTX file editor, which is what python-pptx is. A renderer also has tight coupling to the display platform, which is not well supported in Python, getting things like font-metrics and so forth over the various operating systems like OS X, Linux, and Windows, perhaps depending on display and/or printer drivers, etc.