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, however I don't know where should I look for setting tab spacing for those sign.
from pptx import Presentation
from pptx.util import Inches, Cm, Pt
path_to_presentation = 'your/path/to/file.pptx'
prs = Presentation(path_to_presentation)
list_of_titles = []
list_of_slide_pages = []
...
# some code populating both above mentioned lists
...
# create new slide
tslide_layout = prs.slide_layouts[1]
toc_slide = prs.slides.add_slide(tslide_layout)
# add content to TOC slide
toc_slide.shapes.title.text = 'Table of contents'
for numer, title in enumerate(list_of_titles):
paragraph = toc_slide.shapes[1].text_frame.paragraphs[numer]
paragraph.text = title+'\t'+str(list_of_slide_pages[numer])
paragraph.level = 0
paragraph.runs[0].font.size = Pt(18)
toc_slide.shapes[1].text_frame.add_paragraph()
# save presentation
prs.save('your/path/to/file_with_TOC.pptx')
I am looking for parameters to set distance and alignment for tab stops in this shape/text_frame/paragraph or any other trick to elegantly bypass these parameters in a different way giving the desired final result. Any help or advice will be appreciated.