Questions tagged [python-pptx]

python-pptx is a Python library for creating and updating PowerPoint (.pptx) files.

python-pptx is a Python library for creating and updating PowerPoint (.pptx) files.

Latest documentation

Available from pypi.

734 questions
3
votes
0 answers

How to set tab spacing in shape/paragraph with python-pptx?

I am setting up a final slide with table of content containing all slide titles and related slide numbers from presentation. In this case I work with python-pptx 0.6.18 & Python 3.7. So far I've managed to split title and page number with tab sign,…
Oskar_U
  • 472
  • 4
  • 13
3
votes
2 answers

How can I get the dimensions of a picture placeholder to re-size an image when creating a presentation and inserting a picture using python-pptx?

I'm trying to insert a picture that is re-sized to fit the dimensions of the picture placeholder from a template using python-pptx. I don't believe the API has direct access to this from what I can find out in the docs. Is there any suggestion of…
Robin White
  • 159
  • 2
  • 11
3
votes
2 answers

Python and PowerPoint replace '

' becomes '_x000D_'

I'm creating a PowerPoint with Python pptx and my query result string contains the html '

' and I'm trying to replace it with '\n' like: TDsFirst = "\n" + self.TxtStringFromSQLserver.replace('

', '\n') TDPs = TDPsFirst.replace('
',…
Mattman85208
  • 1,858
  • 2
  • 29
  • 51
3
votes
1 answer

How to add an additional gradient fill stop, besides the default two, for a shape, using python-pptx

I have a shape and can change the shape to use a gradient fill. If it since before have more gradient stops than the default two, I can parse them, change them, and remove them. However, I cannot find how to add an additional gradient stop. Which is…
3
votes
1 answer

Get a picture - Python-pptx

I am trying to read a .pptx file using python-pptx. I managed to get all the content except the image from the presentation. Below is the code i used to identify images other than textframes in the presentation. After identifying i am getting the…
SanthoshSolomon
  • 1,383
  • 1
  • 14
  • 25
3
votes
0 answers

python-pptx: Dealing with password-protected PowerPoint files

I'm using a slightly modified version of the "Extract all text from slides in presentation" example at https://python-pptx.readthedocs.io/en/latest/user/quickstart.html to extract text from some PowerPoint slides. I'm getting a PackageNotFoundError…
BobInBaltimore
  • 425
  • 5
  • 13
3
votes
3 answers

Using Python-pptx, what conditions could a PowerPoint have that give KeyError?

I have a PowerPoint that I would like to open, amend, and save as a different filename. However, I'm getting a KeyError. I tried this code with a blank PowerPoint presentation and it works perfectly. However, when I use the code to ope an existing…
SoSincere3
  • 117
  • 1
  • 10
3
votes
0 answers

Conditional Formatting TypeError: only size-1 arrays can be converted to Python scalars

I am getting an usual error when trying to apply a format using a conditional format and I am unsure what would be causing it. Specifically, the issue seems to be caused by attempting to apply the second conditional formatting in the elif…
adammvg
  • 31
  • 2
3
votes
2 answers

How to change the font size of an python pptx object

I would like to change the font size of the title and of the body of my pptx-presentation. I tried to set it via title_shape.font = Pt(15) and body_shape.font = Pt(10), which does not work. Here is my code: from pptx import Presentation, util,…
Luk-StackOverflow
  • 321
  • 1
  • 5
  • 10
3
votes
2 answers

Extract table from Powerpoint

I am trying to extract table from a PPT using python-pptx, however, the I am not sure how do I that using shape.table. from pptx import Presentation prs = Presentation(path_to_presentation) # text_runs will be populated with a list of strings, # one…
chintan s
  • 6,170
  • 16
  • 53
  • 86
3
votes
1 answer

word wrap data labels python-pptx

Is it possible to set word wrap to false all data labels in my chart? I was trying to do plots[0].data_labels.format.text_frame.word_wrap = False but data_labels hasn't format property
3
votes
1 answer

pptx-python - Powerpoint always opens on master slide page

I have an app that creates powerpoints. Everything goes well except that every time I want to open one of these powerpoints it opens it in the slide master view. This isn't necessarily a problem per se, but just annoying since I open a lot of these…
Ludo
  • 2,307
  • 2
  • 27
  • 58
3
votes
2 answers

create new pptx using existing pptx Python-Pptx

I am trying to create new.pptx using an old.pptx . old.pptx is having 4 slides in it . I want to create the new.pptx with almost same content with few text modifications in 4 slides . I skipped the modification part from the below code, you can take…
RonyA
  • 585
  • 3
  • 11
  • 26
3
votes
0 answers

Python-pptx: copy specific slides to another one

I have several .pptx files to work on, and I want to copy slides which contain specific keyword to another .pptx. For example, for file A.pptx, if there is the keyword(maybe like Apple) in the slide, then it will copy this slide to another…
Lydia Liu
  • 31
  • 2
3
votes
2 answers

How to choose saving directory with python-pptx?

I'm pretty new to python and I've been working on a project with pptx python. Everything is fine, but I don't understand how to choose in which directory my file will be saved. Here is my code: from pptx import Presentation prs =…
Alex Daxe
  • 49
  • 6