跳到主要内容

RemoveSlide

从演示文稿中移除指定位置的幻灯片。

备注

此功能仅在 ONLYOFFICE Docs 付费版本中可用。

语法

expression.RemoveSlide(nIndex);

expression - 表示 ApiPresentation 类的变量。

参数

名称必需/可选数据类型默认值描述
nIndex必需number从零开始的幻灯片索引。

返回值

boolean

示例

从演示文稿中删除单张幻灯片。

// How do I remove a slide at a specific position in a presentation?

// Remove the second slide and display a confirmation message.

const presentation = Api.GetPresentation();
const slide1 = presentation.GetSlideByIndex(0);
slide1.RemoveAllObjects();

const slide2 = Api.CreateSlide();
presentation.AddSlide(slide2);

presentation.RemoveSlide(1);

const fill = Api.CreateSolidFill(Api.RGB(51, 51, 51));
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("The second slide was removed from this presentation.");
slide1.AddObject(shape);