Delete all text?

I am looking to open a document, delete all the text (importantly, leaving the headers and footers) and then pasting new text in using the InsertHtml method.

How can I clear all the text in a document (saving headers/footers)?

It’s a good idea for a new feature given that we already have methods to clear all (including headers and footers) and clear headers and footers only. I will add this in the next hotfix that is due out in a couple of days.

Hi,

Aspose.Word 2.1 is out that provides new Section.ClearStory method to clear main text or any header/footer in a document. For more info see https://docs.aspose.com/words/net/release-notes/

How do I determine which “section” (index into Document.Sections[]) is the main text (everything but the header and footer).

Every section has main text, headers and footers. If you want to delete main text only, you should iterate through all sections and call ClearStory(StoryType.MainTextStory) for each section.