Created
December 9, 2020 15:18
-
-
Save aspose-com-gists/a38246fe270c43b630c91d28b872412f to your computer and use it in GitHub Desktop.
Merge PowerPoint Presentations in Java
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
// Load first presentation | |
Presentation presentation1 = new Presentation("presentation1.pptx"); | |
// Load second presentation | |
Presentation presentation2 = new Presentation("presentation2.pptx"); | |
// Merge slides | |
for (int index = 0; index< presentation2.getSlides().size(); index = index+2) { | |
// Merge slides from source to target | |
presentation1.getSlides().addClone(presentation2.getSlides().get_Item(index)); | |
} | |
// Save the presentation | |
presentation1.save("merged-presentation.pptx", SaveFormat.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
// Load first presentation | |
Presentation presentation1 = new Presentation("presentation1.pptx"); | |
// Load second presentation | |
Presentation presentation2 = new Presentation("presentation2.pptx"); | |
// Merge first two slides only using slide master | |
presentation1.getSlides().addClone(presentation2.getSlides().get_Item(0), presentation1.getMasters().get_Item(0), true); | |
presentation1.getSlides().addClone(presentation2.getSlides().get_Item(1), presentation1.getMasters().get_Item(0), true); | |
// Save the presentation | |
presentation1.save("merged-presentation.pptx", SaveFormat.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
// Load first presentation | |
Presentation presentation1 = new Presentation("presentation1.pptx"); | |
// Load second presentation | |
Presentation presentation2 = new Presentation("presentation2.pptx"); | |
// Merge slides | |
for (ISlide slide : presentation2.getSlides()) { | |
// Merge slides from source to target | |
presentation1.getSlides().addClone(slide); | |
} | |
// Save the presentation | |
presentation1.save("merged-presentation.pptx", SaveFormat.Pptx); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment