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 : ISlideCollectionProperties
| Property | Type | Access | Description |
|---|---|---|---|
Count | int | Read | Number of slides in the collection. |
Methods
AddEmptySlide(ILayoutSlide)
Add a new empty slide with the specified layout.
| Parameter | Type | Description |
|---|---|---|
layout | ILayoutSlide | Layout to apply to the new slide. |
Returns: ISlide
InsertEmptySlide(int, ILayoutSlide)
Insert a new empty slide at the specified index.
| Parameter | Type | Description |
|---|---|---|
index | int | 0-based insertion index. |
layout | ILayoutSlide | Layout to apply. |
Returns: ISlide
AddClone(ISlide)
Clone an existing slide and append it to the collection.
| Parameter | Type | Description |
|---|---|---|
sourceSlide | ISlide | Slide 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);