Get Started
Usage API
More information

ApiMaster

new ApiMaster()

Class representing a slide master.

Methods

Name Description
AddLayout

Adds a layout to the specified slide master.

AddObject

Adds an object (image, shape or chart) to the current slide master.

ClearBackground

Clears the slide master background.

Copy

Creates a copy of the specified slide master object.

Delete

Deletes the specified object from the parent if it exists.

Duplicate

Creates a duplicate of the specified slide master object, adds the new slide master to the slide masters collection.

GetAllCharts

Returns an array with all the chart objects from the slide master.

GetAllDrawings

Returns an array with all the drawing objects from the slide master.

GetAllImages

Returns an array with all the image objects from the slide master.

GetAllShapes

Returns an array with all the shape objects from the slide master.

GetClassType

Returns the type of the ApiMaster class.

GetLayout

Returns a layout of the specified slide master by its position.

GetLayoutsCount

Returns a number of layout objects.

GetTheme

Returns a theme of the slide master.

RemoveLayout

Removes the layouts from the current slide master.

RemoveObject

Removes objects (image, shape or chart) from the current slide master.

SetBackground

Sets the background to the current slide master.

SetTheme

Sets a theme to the slide master. Sets a copy of the theme object.

Example

Copy code
builder.CreateFile("pptx");
var oPresentation = Api.GetPresentation();
var oSlide = oPresentation.GetSlideByIndex(0);
var oMaster = oPresentation.GetMaster(0);
var sType = oMaster.GetClassType();
var nCountBefore = oMaster.GetLayoutsCount();
var oLayout = Api.CreateLayout();
oMaster.AddLayout(0, oLayout);
var nCountAfterAdding = oMaster.GetLayoutsCount();
oMaster.RemoveLayout(0, 2);
var nCountAfterRemoving = oMaster.GetLayoutsCount();
var oFill = Api.CreateSolidFill(Api.CreateRGBColor(61, 74, 107));
var oStroke = Api.CreateStroke(0, Api.CreateNoFill());
var oShape = Api.CreateShape("flowChartMagneticTape", 300 * 36000, 130 * 36000, oFill, oStroke);
oShape.SetPosition(608400, 1267200);
oShape.SetSize(300 * 36000, 130 * 36000);
var oDocContent = oShape.GetDocContent();
var oParagraph = oDocContent.GetElement(0);
oParagraph.SetJc("left");
oParagraph.AddText("Number of layouts before adding new layout: " + nCountBefore);
oParagraph.AddLineBreak();
oParagraph.AddText("Number of layouts after adding new layout: " + nCountAfterAdding);
oParagraph.AddLineBreak();
oParagraph.AddText("Number of layouts after removing two layouts: " + nCountAfterRemoving);
oParagraph.AddLineBreak();
oParagraph.AddText("Class type = " + sType);
oSlide.RemoveAllObjects();
oMaster.AddObject(oShape);
oSlide = Api.CreateSlide();
oPresentation.AddSlide(oSlide);
oMaster = oPresentation.GetMaster(0);
nCountBefore = oPresentation.GetMastersCount();
oMaster.Duplicate(1);
var nCountAfter = oPresentation.GetMastersCount();
oFill = Api.CreateSolidFill(Api.CreateRGBColor(61, 74, 107));
oStroke = Api.CreateStroke(0, Api.CreateNoFill());
oShape = Api.CreateShape("flowChartMagneticTape", 300 * 36000, 130 * 36000, oFill, oStroke);
oShape.SetPosition(608400, 1267200);
oShape.SetSize(300 * 36000, 130 * 36000);
oDocContent = oShape.GetDocContent();
oParagraph = oDocContent.GetElement(0);
oParagraph.SetJc("left");
oParagraph.AddText("Number of masters before duplicating: " + nCountBefore);
oParagraph.AddLineBreak();
oParagraph.AddText("Number of masters after duplicating: " + nCountAfter);
oSlide.RemoveAllObjects();
oSlide.AddObject(oShape);
builder.SaveFile("pptx", "ApiMaster.pptx");
builder.CloseFile();

Resulting document