Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active September 8, 2021 14:12
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/16fa693aad9f16ff60c2e21a80089fc2 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/16fa693aad9f16ff60c2e21a80089fc2 to your computer and use it in GitHub Desktop.
Clone Slides in PowerPoint using Java
// Load presentation file
Presentation pres = new Presentation("presentation.pptx");
try {
// Clone the desired slide to the end of the collection of slides in the same presentation
ISlideCollection slds = pres.getSlides();
slds.addClone(pres.getSlides().get_Item(0));
// Save updated file
pres.save("output.pptx", SaveFormat.Pptx);
} finally {
pres.dispose();
}
// Load source presentation file
Presentation srcPres = new Presentation("source.pptx");
try {
// Load destination PPTX (where slide is to be cloned)
Presentation destPres = new Presentation("destination.pptx");
try {
// Clone the desired slide from the source presentation to specified location in destination presentation
ISlideCollection slds = destPres.getSlides();
slds.insertClone(2, srcPres.getSlides().get_Item(0));
// Save updated destination presentation
destPres.save("output.pptx", SaveFormat.Pptx);
} finally {
destPres.dispose();
}
} finally {
srcPres.dispose();
}
// Load presentation file
Presentation pres = new Presentation("presentation.pptx");
try {
// Access collection of slides in the presentation
ISlideCollection slds = pres.getSlides();
// Clone the desired slide to the specified index in the presentation
slds.insertClone(2, pres.getSlides().get_Item(1));
// Save updated file
pres.save("output.pptx", SaveFormat.Pptx);
} finally {
pres.dispose();
}
// Load source presentation file
Presentation srcPres = new Presentation("source.pptx");
try {
// Load destination PPTX (where slide is to be cloned)
Presentation destPres = new Presentation("destination.pptx");
try {
// Clone the desired slide from the source presentation to the end of the collection of slides in destination presentation
ISlideCollection slds = destPres.getSlides();
slds.addClone(srcPres.getSlides().get_Item(0));
// Save updated destination presentation
destPres.save("output.pptx", SaveFormat.Pptx);
} finally {
destPres.dispose();
}
} finally {
srcPres.dispose();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment