Hello,
I’ve tried the sample code to clone a slide from one presentation to another presentation in the documentation, but it generates an exception:
//Instantiate a Presentation object that represents a PPT file
Presentation pres1 = new Presentation(Resources.getResourceAsStream(“file_1.ppt”));
//Instantiate a Presentation object that represents a PPT file
Presentation pres2 = new Presentation(Resources.getResourceAsStream(“file_2.ppt”));
//Accessing a slide using its slide position
Slide slide = pres1.getSlideByPosition(1);
//Creating TreeMap object that is used to store the temporary information
//about the masters of PPT file. No value should be added to it.
TreeMap tMap = new TreeMap();
//Cloning the selected slide at the end of another presentation file
pres1.cloneSlide(slide, pres1.getSlides().getLastSlidePosition() + 1, pres2, tMap);
//Writing the presentation as a PPT file
pres2.write(new FileOutputStream(new File(“modified.ppt”)));
Exception :
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at com.aspose.slides.Paragraphs.get(SourceFile:44)
at com.aspose.slides.Slide.do(SourceFile:230)
at com.aspose.slides.Presentation.do(SourceFile:1492)
at com.aspose.slides.Presentation.cloneSlide(SourceFile:1639)
Version aspose slides 2.4.0
Dear Thomas,
I have observed the code snippet shared by you and it seems to be fine. The only issue that I feel is with the position of cloned slide inside destination position. You may be cloning the slide at position that actually does not exists in destination presentation. Can you please verify this fact. If you still encounter with the same issue then please share the source presentations with us for necessary investigation to solve your issue.
Thanks and Regards,
Hello,
Thanks for the answer, it’s working now but I always have the exception in logs.
Dear Thomas,
Yes, you are right about the exception logs. An issue with ID 18364 has already been created in our issue tracking system to further investigate and resolve the issue. This thread has also been linked with the issue so that you may be automatically notified, once the issue is resolved.
We are sorry for your inconvenience,