Print Powerpoint slide with python-pptx

Keywords:python 


Question: 

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 Answer: 

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.

 

More Articles


ios - Error: Attempt to present <UIImagePickerController: on <ViewController: while a presentation is in progress

Hey everyone and thank you for reading. I am making an app which you can take pictures and retreive pictures from the camera roll and display it on a view. The problem is that when I try to use the button which brings up the camera roll, I get the error "presentation is in progress" as above in the

r - How to Make RStudio Presentation Self-contained?

I'm writing a presentation in R using RStudio. To create new presentation, I select "R Presentation" from the File => New File menu. RStudio creates new document. Here is the template:New Presentation========================================================author: date: First Slide===================

r - Embed javascript in Xaringan presentation

I have an interactive pooling question created using polleverywhere that would like to insert into my Xaringan rmarkdown presentation:<script src="https://www.polleverywhere.com/multiple_choice_polls/U43TXrlame7hw6J/web.js?height=250&results_count_format=percent&width=300"></script&


objective c - iOS Project Structure for Presentation App

I'm gonna build presentation app, which will present a brandproduct.Presentation will have multiple slides (states) with commonbackground.In some slides I can go back to previous slideMy questions: 1. Do I have to use View Based Application? 2. For each state (slide) should I use separate UIViewCont

android - How to prevent AlertDialog using custom theme from appearing fullscreen?

I am using a custom style for my AlertDialogs, but it is making them appear fullscreen. I've searched around, but I could only seem to find people wanting to make it fullscreen... Here is my style <style name="MyDialog" parent="AlertDialog.AppCompat"> <item name="android:background">

html - CSS - Background-size: Cover is too big

When i try to use the background-size:cover property with a fixed position my image becomes too big, and cropped. I'd like it to be the same size as the original image, but i can't figure this out. I'm trying to keep the affect of the image staying in position.#wrapper { width:100%; height:580px;


How can the CAPTCHA process be more user friendly or better implemented?

I have used CAPTCHA on my various web sites in the standard manner where I generated some obfuscated string of characters (odd pair of words, random number, etc.) in an image for the user to manually reproduce in a text box. I am also aware of recaptcha.net which extends the basic functionality of

xml - python-pptx - How to access presentation section titles programmatically?

In Powerpoint, I'd like to create agenda / table of content slides, with section titles serving as input to these agenda slides. Sections allow one to structure a presentation document. They are particularly useful in the slide-sorter and outline mode. Conveniently leveraging section titles for the

Proper way to present field name-value tuples in HTML?

I have a big form in a page and at some portions of it I have some static data that is not editable:First name: JohnBirthday: 1980/1/1These fields are not part of the form (no input), etc. but rather hard-fixed values. I did try a few things but I am confused as to what is the most appropriate thing

powerpoint - How to retrieve pptx slide name with apache poi

Powerpoint slides have internal names that are accessible and modifiable via VBA.see e.g. Powerpoint: Manually set Slide NameI would like to access the name via apache poi.I tried: public String getName() { CTSlide ctSlide = slide.getXmlObject(); String name=ctSlide.getCSld().getName(); ret