Template request | Bug report | Generate Data Product
Tags: #powerpoint #slide #portrait #pptx #snippet
Author: Florent Ravenel
Description: This notebook allows users to create a new slide in PowerPoint with a textbox.
try:
from pptx import Presentation
except:
!pip install python-pptx --user
from pptx import Presentation
from pptx.util import Inches, Pt
output_pptx = "MyPowerPoint_Slide_Textbox.pptx"
text1 = "This is text inside a textbox"
text2 = "This is a second paragraph that's bold"
text3 = "This is a third paragraph that's big"
prs = Presentation()
prs.slide_height = Inches(11.69)
prs.slide_width = Inches(8.27)
blank_slide_layout = prs.slide_layouts[6]
slide = prs.slides.add_slide(blank_slide_layout)
left = top = width = height = Inches(1)
txBox = slide.shapes.add_textbox(left, top, width, height)
tf = txBox.text_frame
tf.text = text1
p = tf.add_paragraph()
p.text = text2
p.font.bold = True
p = tf.add_paragraph()
p.text = text3
p.font.size = Pt(40)
prs.save(output_pptx)