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.Presentation;
import org.aspose.slides.foss.ISlide;
import org.aspose.slides.foss.IMasterSlide;
import org.aspose.slides.foss.ILayoutSlide;
import org.aspose.slides.foss.SlideLayoutType;
import org.aspose.slides.foss.export.SaveFormat;LayoutSlide
public class LayoutSlide extends BaseSlide implements ILayoutSlideProperties
| Property | Type | Access | Description |
|---|---|---|---|
getMasterSlide() / setMasterSlide(IMasterSlide) | IMasterSlide | Read/Write | The master slide this layout belongs to. |
getLayoutType() | SlideLayoutType | Read | Layout type (title, blank, etc.). |
getPresentation() | IPresentation | Read | Parent presentation. |
MasterSlide
public class MasterSlide extends BaseSlide implements IMasterSlideProperties
| Property | Type | Access | Description |
|---|---|---|---|
getLayoutSlides() | ILayoutSlideCollection | Read | Collection of layout slides for this master. |
getPresentation() | IPresentation | Read | Parent presentation. |
LayoutSlideCollection
public class LayoutSlideCollection implements ILayoutSlideCollectionMethods
| Method | Returns | Description |
|---|---|---|
get(int index) | ILayoutSlide | Get layout by index. |
size() | int | Number of layouts. |
getByType(SlideLayoutType type) | ILayoutSlide | Find a layout by type. |
iterator() | Iterator<ILayoutSlide> | Iterate over layouts. |
MasterSlideCollection
public class MasterSlideCollection implements IMasterSlideCollection, Iterable<IMasterSlide>Methods
| Method | Returns | Description |
|---|---|---|
get(int index) | IMasterSlide | Get master by index. |
size() | int | Number of masters. |
iterator() | Iterator<IMasterSlide> | Iterate over masters. |
Usage Examples
Inspect Masters and Layouts
import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.ISlide;
import org.aspose.slides.foss.IMasterSlide;
import org.aspose.slides.foss.ILayoutSlide;
import org.aspose.slides.foss.SlideLayoutType;
import org.aspose.slides.foss.export.SaveFormat;
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);