LayoutSlide / MasterSlide

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

The LayoutSlide and MasterSlide classes represent layout and master slides in a presentation. Both extend BaseSlide.

Package: org.aspose.slides.foss

import org.aspose.slides.foss.*;

LayoutSlide

public class LayoutSlide extends BaseSlide implements ILayoutSlide

Properties

PropertyTypeAccessDescription
getMasterSlide() / setMasterSlide(IMasterSlide)IMasterSlideRead/WriteThe master slide this layout belongs to.
getLayoutType()SlideLayoutTypeReadLayout type (title, blank, etc.).
getPresentation()IPresentationReadParent presentation.

MasterSlide

public class MasterSlide extends BaseSlide implements IMasterSlide

Properties

PropertyTypeAccessDescription
getLayoutSlides()ILayoutSlideCollectionReadCollection of layout slides for this master.
getPresentation()IPresentationReadParent presentation.

LayoutSlideCollection

public class LayoutSlideCollection implements ILayoutSlideCollection

Methods

MethodReturnsDescription
get(int index)ILayoutSlideGet layout by index.
size()intNumber of layouts.
getByType(SlideLayoutType type)ILayoutSlideFind a layout by type.
iterator()Iterator<ILayoutSlide>Iterate over layouts.

MasterSlideCollection

public class MasterSlideCollection implements IMasterSlideCollection, Iterable<IMasterSlide>

Methods

MethodReturnsDescription
get(int index)IMasterSlideGet master by index.
size()intNumber of masters.
iterator()Iterator<IMasterSlide>Iterate over masters.

Usage Examples

Inspect Masters and Layouts

import org.aspose.slides.foss.*;

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

for (int i = 0; i < prs.getMasters().size(); i++) {
    IMasterSlide master = prs.getMasters().get(i);
    System.out.println("Master " + i + ": " + master.getName()
        + " (" + master.getLayoutSlides().size() + " layouts)");
}

Get a Layout by Type

IMasterSlide master = prs.getMasters().get(0);
ILayoutSlide titleLayout = master.getLayoutSlides().getByType(SlideLayoutType.TITLE);

Apply a Layout to a Slide

ISlide slide = prs.getSlides().get(0);
slide.setLayoutSlide(titleLayout);
prs.save("relayouted.pptx", SaveFormat.PPTX);

See Also