Merging slides (read slides from multiple PPTs and copy slides into new Presentation)

Hi Iam reading the multiple PPTs, which each PPT has single slide and iam trying to copy all these slides into new Presentation.

here is my code:

File dir = new File("D://output");

String[] children = dir.list();

if (children == null) {

System.out.println(" **** Directory is Empty ****");

} else {

for (int i=0; i<children.length; i++) {

String filename = children[i];




Presentation srcPres = new Presentation(new FileInputStream( dir + "/" + filename ));

Point size = new Point(3,3);

Presentation newPres = new Presentation();


TreeMap ids = new TreeMap();

for (int iSlidesCounter = 0; iSlidesCounter < children.length; iSlidesCounter++) {


newPres.cloneSlide(newPres.getSlides().get(0), srcPres.getSlides().getLastSlidePosition()+1, srcPres, ids);

srcPres.write(new FileOutputStream("d://output/newslide.ppt"));

With the above code iam not able to copy the slides into new Presentation.

Could any one please help me, where iam doing wrong.




You should see the cloneslide demo code. You can find it aspose.slides\examples\cloneslide directory, when you unzip Aspose.Slides for JAVA.

For your convenience, I have also attached its code.

You should note down few things. Always use Presentation.getSlideByPostion() to get reference to normal slide and position starts from 1, don’t use Presentation.getSlides().get()

Also, note down the order of the Presentation object for cloneslide method.

If you are cloning slide from pres1 to pres2, it will look like this

pres1.CloneSlide(pres1Slide, slideposition, pres2, new TreeMap());