Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active January 25, 2022 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/603b0e997ea07b37a82d910a1c03d3b1 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/603b0e997ea07b37a82d910a1c03d3b1 to your computer and use it in GitHub Desktop.
Merge PowerPoint PPT/PPTX Presentations in Python
import aspose.slides as slides
# open first PPT
with slides.Presentation("Presentation1.pptx") as pres1:
# open second PPT
with slides.Presentation("Presentation2.pptx") as pres2:
# loop through slides
for slide in pres2.slides:
# clone slide
pres1.slides.add_clone(slide, pres1.masters[0], allow_clone_missing_layout = True)
# save merged PPT
pres1.save("combined.pptx", slides.export.SaveFormat.PPTX)
import aspose.slides as slides
# open first PPT
with slides.Presentation("Presentation1.pptx") as pres1:
# open second PPT
with slides.Presentation("Presentation2.pptx") as pres2:
# loop through slides
for slide in pres2.slides:
# clone slide
pres1.slides.add_clone(slide, pres1.sections[0])
# save merged PPT
pres1.save("combined.pptx", slides.export.SaveFormat.PPTX)
import aspose.slides as slides
# open first PPT
with slides.Presentation("Presentation1.pptx") as pres1:
# open second PPT
with slides.Presentation("Presentation2.pptx") as pres2:
# change size of slides
pres2.slide_size.set_size(pres1.slide_size.size.width, pres1.slide_size.size.height, slides.SlideSizeScaleType.ENSURE_FIT)
# loop through slides
for slide in pres2.slides:
# clone slide
pres1.slides.add_clone(slide)
# save merged PPT
pres1.save("combined.pptx", slides.export.SaveFormat.PPTX)
import aspose.slides as slides
# open first PPT
with slides.Presentation("presentation1.pptx") as pres1:
# open second PPT
with slides.Presentation("Presentation2.pptx") as pres2:
# loop through slides
for slide in pres2.slides:
# clone slide
pres1.slides.add_clone(slide)
# save merged PPT
pres1.save("combined.pptx", slides.export.SaveFormat.PPTX)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment