Free Support Forum - aspose.com

Cloning Slides with Pictures

Hello,

I am attempting to copy slides from one presentation to another using Presentation.cloneSlide(). The slide that is being cloned has a picture on it. After I save the presentation, the new page with the picture has everything on it except for the picture. Are there any restrictions about what type of slides can be cloned?

I have attached my test program and two input files, as well as the resultant output file. If you run the test program, it will copy "second.ppt" to the end of "first.ppt" and overwrite "output.ppt".

I am using the most recent version of Aspose.PowerPoint for Java.

Thank you,
Randy Stegbauer

I don’t see your program and files but you should use cloneSlide with 4 parameters

to copy slides from one presentation to another.

Alexey,

I attached the zip file again with my test program. I hope it works.

I'll try to use the four parameter cloneSlide. Where should the TreeMap come from, or is it just a newly created empty map?

Here is the pseudo-code I will use. Does it look ok to you?

Presentation pres1 = new Presentation(new FileInputStream("first.ppt"));
Presentation pres2 = new Presentation(new FileInputStream("second.ppt"));
pres1.cloneSlide(pres2.getSlideByPosition(1), 2, pres2, new TreeMap());
pres1.write(new FileOutputStream(new File("output.ppt")));

Thanks,
Randy Stegbauer

Alexey,

I just realized that the third line above should have been:

pres1.cloneSlide(pres2.getSlideByPosition(1), 2, pres1, new TreeMap());

I changed the test program and ran it again, but it still fails exactly the same way.

Thank you,
Randy Stegbauer

  1. cloneSlide should be called from source presentation.
  2. third parameter is target presentation.



    pres2.cloneSlide(pres2.getSlideByPosition(1), 2, pres1, new TreeMap());

Alexey,

Excellent! It works perfectly now.

Thank you,
Randy Stegbauer