https://python-pptx.readthedocs.io/en/latest/
from pptx import Presentation
import tempfile
import s3fs
fs = s3fs.S3FileSystem()
prs = Presentation()
title_slide_layout = prs.slide_layouts[0]
slide = prs.slides.add_slide(title_slide_layout)
title = slide.shapes.title
subtitle = slide.placeholders[1]
title.text = "Hello, World!"
subtitle.text = "python-pptx was here!"
with tempfile.NamedTemporaryFile() as f:
prs.save(f.name)
fs.put_file(f.name, "BUCKET/title.pptx")
prs = Presentation()
bullet_slide_layout = prs.slide_layouts[1]
slide = prs.slides.add_slide(bullet_slide_layout)
shapes = slide.shapes
title_shape = shapes.title
body_shape = shapes.placeholders[1]
title_shape.text = "Adding a Bullet Slide"
tf = body_shape.text_frame
tf.text = "Find the bullet slide layout"
p = tf.add_paragraph()
p.text = "Use _TextFrame.text for first bullet"
p.level = 1
p = tf.add_paragraph()
p.text = "Use _TextFrame.add_paragraph() for subsequent bullets"
p.level = 2
with tempfile.NamedTemporaryFile() as f:
prs.save(f.name)
fs.put_file(f.name, "BUCKET/bullet.pptx")
with fs.open("BUCKET/title.pptx") as f:
prs1 = Presentation(f)
with fs.open("BUCKET/bullet.pptx") as f:
prs2 = Presentation(f)
prs = Presentation()
slide = prs.slides.add_slide(prs.slide_layouts[0])
slide.shapes.title.text = prs1.slides[0].shapes.title.text
slide.placeholders[1].text = prs1.slides[0].placeholders[1].text
slide = prs.slides.add_slide(prs.slide_layouts[1])
slide.shapes.title.text = prs2.slides[0].shapes.title.text
slide.shapes.placeholders[1].text_frame.text = prs2.slides[0].shapes.placeholders[1].text_frame.text
with tempfile.NamedTemporaryFile() as f:
prs.save(f.name)
fs.put_file(f.name, "BUCKET/combined.pptx")