Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print Powerpoint slide with python-pptx

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
like image 701
Neil Avatar asked May 17 '26 18:05

Neil


1 Answers

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.

like image 179
scanny Avatar answered May 22 '26 04:05

scanny



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!