Skip to content

Add Bullet list on existing slides doesn't works #807

@FPRM

Description

@FPRM

Python == 3.7
python-pptx==0.6.21

I try to create a simple bullet list in an existing presentation template on an existing slide.
by Following the exemple on the read the doc page everything works but the example requires to create a new slide.
i want to add my bullet list on as specific space in a specific place, and it doesn't work.

My code is as following

from pptx import Presentation
from pptx.util import Cm , Pt
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN


# list of bulleted element
paragraph_strs = [
    'test item1',
    'test item2',
    'test item3'
]
# Open Templatetes and position on slide 2
prs = Presentation('emptytest.pptx')
docslide = prs.slides[1]

# create text box according to template needed
txBox = docslide.shapes.add_textbox(Cm(2), Cm(2), Cm(17.15), Cm(5))
tf = txBox.text_frame
# iterate bullet list and add text as paragraph
for para_str in paragraph_strs:
    p = tf.add_paragraph()
    p.text = para_str
    p.alignment = PP_ALIGN.LEFT
    font = p.font
    font.name = 'Ubuntu'
    font.size = Pt(12)
    p.font.color.rgb = RGBColor(140, 140, 140)
    p.level = 1

prs.save('testoutput.pptx')

And the result is
https://i.imgur.com/IfgmfHz.png
as my desired output should look like.
https://i.imgur.com/Hi5bGpm.png
And if i may ask a nice to have question, would be to have bullets formated in dedicated color like
https://imgur.com/UrrsBu8

Thanks a lot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions