跳到主要内容

CreateMaster

创建新的幻灯片母版。

语法

expression.CreateMaster(oTheme);

expression - 表示 Api 类的变量。

参数

名称必需/可选数据类型默认值描述
oTheme可选ApiThemeApiPresentation.GetMaster(0).GetTheme()演示文稿主题对象。

返回值

ApiMaster

示例

此示例演示如何创建幻灯片母版。

// How to add master to the slide.

// Create new slide master and apply it to the slide.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
const master = Api.CreateMaster();

let countBefore = presentation.GetMastersCount();
presentation.AddMaster(countBefore, master);
let countAfter = presentation.GetMastersCount();

const fill = Api.CreateSolidFill(Api.RGB(255, 111, 61));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = Api.CreateShape("flowChartMagneticTape", 300 * 36000, 130 * 36000, fill, stroke);
shape.SetPosition(608400, 1267200);

const docContent = shape.GetDocContent();
const paragraph = docContent.GetElement(0);
paragraph.AddText("Number of masters before adding new master: " + countBefore);
paragraph.AddLineBreak();
paragraph.AddText("Number of masters after adding new master: " + countAfter);

slide.RemoveAllObjects();
slide.AddObject(shape);