LayoutSlide / MasterSlide — Aspose.Slides FOSS for .NET API Reference

Layout slides and master slides define the visual templates for presentation slides. Each slide references a LayoutSlide, which in turn references a MasterSlide.

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

using Aspose.Slides.Foss;

LayoutSlide

public class LayoutSlide : BaseSlide, ILayoutSlide

Inheritance

BaseSlideLayoutSlide

Properties

PropertyTypeAccessDescription
MasterSlideIMasterSlide?ReadParent master slide.
LayoutTypeSlideLayoutTypeReadLayout type (Blank, Title, TitleAndContent, etc.).
ShapesIShapeCollection?ReadShapes on the layout (inherited from BaseSlide).
NamestringReadLayout name (inherited from BaseSlide).

MasterSlide

public class MasterSlide : BaseSlide, IMasterSlide

Inheritance

BaseSlideMasterSlide

Properties

PropertyTypeAccessDescription
LayoutSlidesIMasterLayoutSlideCollectionReadLayouts belonging to this master.
ShapesIShapeCollection?ReadShapes on the master (inherited from BaseSlide).
NamestringReadMaster name (inherited from BaseSlide).

Collections

GlobalLayoutSlideCollection

Accessed via Presentation.LayoutSlides. Contains all layouts across all masters.

MethodReturnsDescription
GetByType(SlideLayoutType type)ILayoutSlide?Find a layout by type.
CountintNumber of layout slides.

MasterSlideCollection

Accessed via Presentation.Masters.

MethodReturnsDescription
AddClone(IMasterSlide sourceMaster)IMasterSlideClone a master slide.
CountintNumber of master slides.

MasterLayoutSlideCollection

Accessed via MasterSlide.LayoutSlides.

MethodReturnsDescription
GetByType(SlideLayoutType type)ILayoutSlide?Find a layout by type within this master.
CountintNumber of layouts in this master.

Usage Examples

List Layouts and Masters

using Aspose.Slides.Foss;

using var prs = new Presentation("deck.pptx");

Console.WriteLine($"Masters: {prs.Masters.Count}");
foreach (var master in prs.Masters)
{
    Console.WriteLine($"  Master: {master.Name} ({master.LayoutSlides.Count} layouts)");
}

Console.WriteLine($"Total layouts: {prs.LayoutSlides.Count}");

Add a Slide with a Specific Layout

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

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

Console.WriteLine($"Slides: {prs.Slides.Count}");
prs.Save("with-blank.pptx", SaveFormat.Pptx);

See Also