clearContent method

clearContent()

Clears the section.

clearContent()

Remarks

The text of Section.body is cleared, only one empty paragraph is left that represents the section break.

The text of all headers and footers is cleared, but HeaderFooter objects themselves are not removed.

Examples

Shows how to clear the contents of a section.

let doc = new aw.Document();
let builder = new aw.DocumentBuilder(doc);

builder.write("Hello world!");

expect(doc.getText().trim()).toEqual("Hello world!");
expect(doc.firstSection.body.paragraphs.count).toEqual(1);

// Running the "ClearContent" method will remove all the section contents
// but leave a blank paragraph to add content again.
doc.firstSection.clearContent();

expect(doc.getText().trim()).toEqual('');
expect(doc.firstSection.body.paragraphs.count).toEqual(1);

See Also