How to set the layout of the slide in Java

This article will demonstrate how to set the layout of the slide via Spire.Presentation in Java applications. There are 11 kinds of layout on Microsoft PowerPoint and Spire.Presentation supports all of them.

How to set the layout of the slide in Java

Set one layout of the slide

import com.spire.presentation.*;

public class setSlideLayout {
    public static void main(String[] args) throws Exception{

        //Create an instance of presentation document
        Presentation ppt = new Presentation();

        //Remove the default slide
        ppt.getSlides().removeAt(0);

        //Append a slide and set the layout for slide
        ISlide slide = ppt.getSlides().append(SlideLayoutType.TITLE);

        //Add content for Title and Text
        IAutoShape shape = (IAutoShape)slide.getShapes().get(0);
        shape.getTextFrame().setText("Spire.Presentation");

        shape = (IAutoShape)slide.getShapes().get(1);
        shape.getTextFrame().setText("Set the Layout of Slide as Title");

        //Save the document
         ppt.saveToFile("SlideLayout.pptx", FileFormat.PPTX_2013);
        ppt.dispose();
    }
}

How to set the layout of the slide in Java

Set the different layout of the slides

import com.spire.presentation.*;

public class setDifferentSlideLayout {
    public static void main(String[] args) throws Exception{

        //Create a PPT document
        Presentation presentation = new Presentation();

        //Remove the default slide
        presentation.getSlides().removeAt(0);

        //Loop through slide layouts
        for (SlideLayoutType type : SlideLayoutType.values())
        {
            //Append slide by specified slide layout
            presentation.getSlides().append(type);
        }

        //Save the document
        presentation.saveToFile("Result.pptx", FileFormat.PPTX_2013);
        presentation.dispose();
    }
}

Effective screenshot:

How to set the layout of the slide in Java