Skip to content

Instantly share code, notes, and snippets.

@conholdate-gists
Created November 13, 2024 13:37
Show Gist options
  • Save conholdate-gists/18ef4df9de62b5428ec952aaf8a39d5c to your computer and use it in GitHub Desktop.
Save conholdate-gists/18ef4df9de62b5428ec952aaf8a39d5c to your computer and use it in GitHub Desktop.
Merge PowerPoint Presentation in Java | Combine Slides
com.aspose.slides.Presentation pres1 = new com.aspose.slides.Presentation("pres1.pptx");
try {
com.aspose.slides.Presentation pres2 = new com.aspose.slides.Presentation("pres2.pptx");
try {
for(com.aspose.slides.ISlide slide : pres2.getSlides())
{
pres1.getSlides().addClone(slide);
}
} finally {
if (pres2 != null) pres2.dispose();
}
pres1.save("combined.pptx", com.aspose.slides.SaveFormat.Pptx);
} finally {
if (pres1 != null) pres1.dispose();
}
com.aspose.slides.Presentation pres1 = new com.aspose.slides.Presentation("pres1.pptx");
try {
com.aspose.slides.Presentation pres2 = new com.aspose.slides.Presentation("pres2.pptx");
try {
for(com.aspose.slides.ISlide slide : pres2.getSlides())
{
pres1.getSlides().addClone(slide, pres2.getMasters().get_Item(0), true);
}
} finally {
if (pres2 != null) pres2.dispose();
}
pres1.save("combined.pptx", com.aspose.slides.SaveFormat.Pptx);
} finally {
if (pres1 != null) pres1.dispose();
}
com.aspose.slides.Presentation pres1 = new com.aspose.slides.Presentation("pres1.pptx");
try {
com.aspose.slides.Presentation pres2 = new com.aspose.slides.Presentation("pres2.pptx");
try {
for(com.aspose.slides.ISlide slide : pres2.getSlides())
{
pres1.getSlides().addClone(slide, pres2.getLayoutSlides().get_Item(0));
}
} finally {
if (pres2 != null) pres2.dispose();
}
pres1.save("combined.pptx", com.aspose.slides.SaveFormat.Pptx);
} finally {
if (pres1 != null) pres1.dispose();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment