Created
April 21, 2024 18:08
-
-
Save documentprocessing/9bd5a651ed3c958f318b7d0466a36a11 to your computer and use it in GitHub Desktop.
Add Textbox to Presentation with python-pptx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pptx import Presentation | |
from pptx.util import Inches, Pt | |
presentation = Presentation() | |
blank_slide_layout = presentation.slide_layouts[6] | |
slide = presentation.slides.add_slide(blank_slide_layout) | |
#set the dimensions of the text box | |
left = top = width = height = Inches(1) | |
txBox = slide.shapes.add_textbox(left, top, width, height) | |
tf = txBox.text_frame | |
tf.text = "Adding text to a textbox in slide" | |
p = tf.add_paragraph() | |
p.text = "A second paragraph in bold" | |
p.font.bold = True | |
p = tf.add_paragraph() | |
p.text = "A big third paragraph" | |
p.font.size = Pt(40) | |
presentation.save('textBox_in_presentation.pptx') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment