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 ISlideCollection

Methods

MethodReturnsDescription
get(int index)ISlideGet slide by zero-based index.
size()intNumber of slides in the collection.
addClone(ISlide sourceSlide)ISlideClone a slide and append to the end.
addClone(ISlide sourceSlide, ILayoutSlide destLayout)ISlideClone a slide with a specific layout.
addClone(ISlide sourceSlide, IMasterSlide destMaster, boolean allowCloneMissingLayout)ISlideClone a slide with a specific master.
insertClone(int index, ISlide sourceSlide)ISlideClone a slide and insert at the given index.
insertClone(int index, ISlide sourceSlide, ILayoutSlide destLayout)ISlideClone and insert with a specific layout.
insertClone(int index, ISlide sourceSlide, IMasterSlide destMaster, boolean allowCloneMissingLayout)ISlideClone 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);

See Also