RemoveAllElements
Removes all the elements from the current document or from the current document element. 💡 When all elements are removed, a new empty paragraph is automatically created. If you want to add content to this paragraph, use the ApiDocumentContent#GetElement method.
Syntax
expression.RemoveAllElements();
expression
- A variable that represents a ApiDocumentContent class.
Parameters
This method doesn't have any parameters.
Returns
boolean
Example
This example shows how to remove all elements from a shape.
- Code
- Result
// How to remove all elements from the slide shape.
// Get a slide shape's content and remove all elements from it.
const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();
const fill = Api.CreateSolidFill(Api.CreateRGBColor(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();
let paragraph = docContent.GetElement(0);
paragraph.AddText("This is just a sample paragraph.");
docContent.RemoveAllElements();
paragraph = Api.CreateParagraph();
paragraph.AddText("We removed all elements from the shape and added a new paragraph inside it.");
docContent.Push(paragraph);
slide.AddObject(shape);