SectionEnsureMinimum Method

Ensures that the section has Body with one Paragraph.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.7.0


public void EnsureMinimum()


Shows how to prepare a new section node for editing.
Document doc = new Document();

// A blank document comes with a section, which has a body, which in turn has a paragraph,
// so we can edit the document by adding children to the paragraph like shapes or runs of text
Assert.AreEqual(2, doc.Sections[0].GetChildNodes(NodeType.Any, true).Count);

// If we add a new section like this, it will not have a body or a paragraph that we can edit
doc.Sections.Add(new Section(doc));

Assert.AreEqual(0, doc.Sections[1].GetChildNodes(NodeType.Any, true).Count);

// Makes sure that the section contains a body with at least one paragraph

// Now we can add content to this section
Assert.AreEqual(2, doc.Sections[1].GetChildNodes(NodeType.Any, true).Count);

See Also