SlideCollection — Aspose.Slides FOSS for .NET API Reference

The SlideCollection class manages the ordered collection of slides in a presentation. Access it via Presentation.Slides.

Package: Aspose.Slides.Foss (net9.0)

using Aspose.Slides.Foss;
public class SlideCollection : ISlideCollection

Properties

PropertyTypeAccessDescription
CountintReadNumber of slides in the collection.

Methods

AddEmptySlide(ILayoutSlide)

Add a new empty slide with the specified layout.

ParameterTypeDescription
layoutILayoutSlideLayout to apply to the new slide.

Returns: ISlide

InsertEmptySlide(int, ILayoutSlide)

Insert a new empty slide at the specified index.

ParameterTypeDescription
indexint0-based insertion index.
layoutILayoutSlideLayout to apply.

Returns: ISlide

AddClone(ISlide)

Clone an existing slide and append it to the collection.

ParameterTypeDescription
sourceSlideISlideSlide to clone.

Returns: ISlide

AddClone(ISlide, ILayoutSlide)

Clone a slide using a specific destination layout.

AddClone(ISlide, IMasterSlide, bool)

Clone a slide using a specific destination master.

InsertClone(int, ISlide)

Clone a slide and insert it at the specified index.

Remove(ISlide)

Remove a slide from the collection.

RemoveAt(int)

Remove the slide at the specified index.

IndexOf(ISlide)

Return the 0-based index of a slide.

ToArray()

Return all slides as an array.


Usage Examples

Add and Clone Slides

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Export;

using var prs = new Presentation();
var layout = prs.LayoutSlides.GetByType(SlideLayoutType.Blank);
prs.Slides.AddEmptySlide(layout);

// Clone the first slide
prs.Slides.AddClone(prs.Slides[0]);

Console.WriteLine($"Total slides: {prs.Slides.Count}");
prs.Save("multi.pptx", SaveFormat.Pptx);

See Also