Skip to content

Instantly share code, notes, and snippets.

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/a38246fe270c43b630c91d28b872412f to your computer and use it in GitHub Desktop.
Save aspose-com-gists/a38246fe270c43b630c91d28b872412f to your computer and use it in GitHub Desktop.
Merge PowerPoint Presentations in Java
// 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);
// 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);
// 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