Get Started
Usage API
More information

ApiLayout

new ApiLayout()

Class representing a slide layout.

Methods

Name Description
AddObject

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

ClearBackground

Clears the slide layout background.

Copy

Creates a copy of the specified slide layout object.

Delete

Deletes the specified object from the parent slide master if it exists.

Duplicate

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

FollowMasterBackground

Sets the master background as the background of the layout.

GetAllCharts

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

GetAllDrawings

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

GetAllImages

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

GetAllShapes

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

GetClassType

Returns the type of the ApiLayout class.

GetMaster

Returns the parent slide master of the current layout.

MoveTo

Moves the specified layout to a specific location within the same collection.

RemoveObject

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

SetBackground

Sets the background to the current slide layout.

SetName

Sets a name to the current layout.

Example

Copy code
builder.CreateFile("pptx");
var oPresentation = Api.GetPresentation();
var oSlide = oPresentation.GetSlideByIndex(0);
oSlide.RemoveAllObjects();
var oMaster = oPresentation.GetMaster(0);
var oLayout = oMaster.GetLayout(0);
var oGs1 = Api.CreateGradientStop(Api.CreateRGBColor(255, 218, 185), 0);
var oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(238, 203, 173), 100000);
var oFill = Api.CreateRadialGradientFill([oGs1, oGs2]);
oLayout.SetBackground(oFill);
oSlide.FollowLayoutBackground();
oSlide = Api.CreateSlide();
oPresentation.AddSlide(oSlide);
oLayout.ClearBackground();
oSlide.FollowLayoutBackground();
oLayout.SetName("New layout");
var sType = oLayout.GetClassType();
oSlide.RemoveAllObjects();
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("A new name was set to the current layout.");
oParagraph.AddLineBreak();
oParagraph.AddText("Class type = " + sType);
oLayout.AddObject(oShape);
builder.SaveFile("pptx", "ApiLayout.pptx");
builder.CloseFile();

Resulting document