Create and edit Master and Layout slides

13 Feb 20193 minutes to read

To get all the slides in same format, you should perform those changes in the Slide Master or Layout Master. The changes will be applied to all the slides, which inherits the master slide or layout slide.

The Syncfusion PowerPoint library supports the following:

  1. Access the MasterSlide in PowerPoint file.
  2. Add LayoutSlide to the MasterSlide.
  3. Customize the LayoutSlide.
  4. Create a slide with 9 pre-defined layout slides.
  5. Customize the layout slides to fit your own scenarios.

Access the MasterSlide

In PowerPoint presentation, the MasterSlide is the top slide that controls all information about the theme, layout, background, color, fonts, and positioning of all slides. Using this MasterSlide, you can easily adjust the look of an existing theme or make overall changes to all your slides.

The following code example demonstrates how to access the MasterSlide in a PowerPoint presentation.

//Create a PowerPoint presentation

IPresentation pptxDoc = Presentation.Create();

//Access the first master slide in PowerPoint file

IMasterSlide masterSlide = pptxDoc.Masters[0];

//Get the first shape name from the master slide

string shapeName = masterSlide.Shapes[0].ShapeName;

//Save the PowerPoint file

pptxDoc.Save("Sample.pptx");

//Close the Presentation instance

pptxDoc.Close();
'Create a PowerPoint presentation

Dim pptxDoc As IPresentation = Presentation.Create()

'Access the first master slide in PowerPoint file.

Dim masterSlide As IMasterSlide = pptxDoc.Masters(0)

'Get the first shape name from the master slide

Dim shapeName As String = masterSlide.Shapes(0).ShapeName

'Save the PowerPoint file.

pptxDoc.Save("AccessMasterSlide.pptx")

'Close the Presentation instance

pptxDoc.Close()

Create a custom LayoutSlide

The real-world scenarios always require more predefined templates. The Syncfusion PowerPoint library lets you build your own custom layout designs and use them to create individual slides.

The following code example demonstrates how to create new custom layout slide and access layout slide in Presentation.

//Create a PowerPoint instance
IPresentation pptxDoc = Presentation.Create();

//Add a new LayoutSlide to the PowerPoint file
ILayoutSlide layoutSlide = pptxDoc.Masters[0].LayoutSlides.Add(SlideLayoutType.Blank, "CustomLayout");

//Add a shape to the LayoutSlide
IShape shape = layoutSlide.Shapes.AddShape(AutoShapeType.Diamond, 30, 20, 400, 300);

//Change the background color for LayoutSlide
layoutSlide.Background.Fill.SolidFill.Color = ColorObject.FromArgb(78, 89, 90);

//Save the PowerPoint file
pptxDoc.Save("LayoutSlide.pptx");

//Close the Presentation instance
pptxDoc.Close();
'Creates a PowerPoint instance
Dim pptxDoc As IPresentation = Presentation.Create()

'Add a new LayoutSlide to the PowerPoint file
Dim layoutSlide As ILayoutSlide = pptxDoc.Masters(0).LayoutSlides.Add(SlideLayoutType.Blank, "CustomLayout")

'Add a shape to the LayoutSlide
Dim shape As IShape = layoutSlide.Shapes.AddShape(AutoShapeType.Diamond, 30, 20, 400, 300)

'Change the background color for LayoutSlide
layoutSlide.Background.Fill.SolidFill.Color = ColorObject.FromArgb(78, 89, 90)

'Save the PowerPoint file
pptxDoc.Save("LayoutSlide.pptx")

'Close the Presentation instance
pptxDoc.Close()