DocumentEnsureMinimum Method

If the document contains no sections, creates one section with one paragraph.

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


public void EnsureMinimum()


Shows how to ensure the Document is valid (has the minimum nodes required to be valid).
Document doc = new Document();

// Every blank document that we create will contain
// the minimal set nodes requited for editing; a Section, Body and Paragraph
Assert.AreEqual(3, doc.GetChildNodes(NodeType.Any, true).Count);

// We can remove every node from the document with RemoveAllChildren()
Assert.AreEqual(0, doc.GetChildNodes(NodeType.Any, true).Count);

// EnsureMinimum() can ensure that the document has at least those three nodes
Assert.AreEqual(3, doc.GetChildNodes(NodeType.Any, true).Count);

See Also