Free Support Forum - aspose.com

Clear content but NOT header and footer

I am using the following code that I have ported over and made changes from the older Aspose.Word component (I am currently using 3.5.1.0). I am trying to clear the text, but NOT the header and footer. Is this code correct for that purpose? If so, why might headers and footers be deleted?

Aspose.Words.Section sec=doc.Sections[0];

sec.ClearContent();

// This is what I did in the old Aspose.Word code which worked
// doc.Sections[0].ClearStory(Aspose.Words.StoryType.MainTextStory);

The following code removes section content but keeps headers/footers:

section.Body.RemoveAllChildren();

section.Body.EnsureMinimum();

Thanks. I will try that.