Aspose::Words::Section::ClearContent method

Section::ClearContent method

Clears the section.

void Aspose::Words::Section::ClearContent()

Remarks

The text of 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.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);

builder->Write(u"Hello world!");

ASSERT_EQ(u"Hello world!", doc->GetText().Trim());
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->get_Paragraphs()->get_Count());

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

ASSERT_EQ(String::Empty, doc->GetText().Trim());
ASSERT_EQ(1, doc->get_FirstSection()->get_Body()->get_Paragraphs()->get_Count());

See Also