BodyEnsureMinimum Method |
Namespace: Aspose.Words
// Open a document Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.Write("Section 1"); builder.InsertBreak(BreakType.SectionBreakNewPage); builder.Write("Section 2"); // This shows what is in the document originally // The document has two sections Console.WriteLine(doc.GetText()); // Loop through all sections in the document foreach (Section section in doc.Sections.OfType<Section>()) { // Each section has a Body node that contains main story (main text) of the section Body body = section.Body; // This clears all nodes from the body body.RemoveAllChildren(); // Technically speaking, for the main story of a section to be valid, it needs to have // at least one empty paragraph. That's what the EnsureMinimum method does body.EnsureMinimum(); } // Check how the content of the document looks now Console.WriteLine(doc.GetText());