SlideCollection — Aspose.Slides FOSS for Java API Reference
The SlideCollection class represents the ordered collection of slides in a presentation. It implements ISlideCollection.
Package: org.aspose.slides.foss
import org.aspose.slides.foss.*;public class SlideCollection implements ISlideCollectionMethods
| Method | Returns | Description |
|---|---|---|
get(int index) | ISlide | Get slide by zero-based index. |
size() | int | Number of slides in the collection. |
addClone(ISlide sourceSlide) | ISlide | Clone a slide and append to the end. |
addClone(ISlide sourceSlide, ILayoutSlide destLayout) | ISlide | Clone a slide with a specific layout. |
addClone(ISlide sourceSlide, IMasterSlide destMaster, boolean allowCloneMissingLayout) | ISlide | Clone a slide with a specific master. |
insertClone(int index, ISlide sourceSlide) | ISlide | Clone a slide and insert at the given index. |
insertClone(int index, ISlide sourceSlide, ILayoutSlide destLayout) | ISlide | Clone and insert with a specific layout. |
insertClone(int index, ISlide sourceSlide, IMasterSlide destMaster, boolean allowCloneMissingLayout) | ISlide | Clone and insert with a specific master. |
toArray() | ISlide[] | Convert the collection to an array. |
toArray(int startIndex, int count) | ISlide[] | Convert a range to an array. |
asICollection() | List<ISlide> | Return slides as a List. |
asIEnumerable() | Iterable<ISlide> | Return slides as an Iterable. |
Usage Examples
Iterate Over Slides
import org.aspose.slides.foss.*;
Presentation prs = new Presentation("deck.pptx");
ISlideCollection slides = prs.getSlides();
for (int i = 0; i < slides.size(); i++) {
ISlide slide = slides.get(i);
System.out.println("Slide " + i + ": " + slide.getShapes().size() + " shapes");
}Clone a Slide
ISlide original = prs.getSlides().get(0);
ISlide clone = prs.getSlides().addClone(original);
prs.save("cloned.pptx", SaveFormat.PPTX);