Learn how to clone slides in PowerPoint presentations using Java: https://blog.aspose.com/2021/08/08/clone-slides-in-powerpoint-using-java/
Last active
September 8, 2021 14:12
-
-
Save aspose-com-gists/16fa693aad9f16ff60c2e21a80089fc2 to your computer and use it in GitHub Desktop.
Clone Slides in PowerPoint using 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 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(); | |
} |
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 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(); | |
} |
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 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(); | |
} |
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 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