DocumentBase class

Provides the abstract base class for a main document and a glossary document of a Word document.

public abstract class DocumentBase : CompositeNode


Name Description
BackgroundShape { get; set; } Gets or sets the background shape of the document. Can be null.
ChildNodes { get; } Gets all immediate child nodes of this node.
Count { get; } Gets the number of immediate children of this node.
CustomNodeId { get; set; } Specifies custom node identifier.
override Document { get; }
FirstChild { get; } Gets the first child of the node.
FontInfos { get; } Provides access to properties of fonts used in this document.
HasChildNodes { get; } Returns true if this node has any child nodes.
override IsComposite { get; } Returns true as this node can have child nodes.
LastChild { get; } Gets the last child of the node.
Lists { get; } Provides access to the list formatting used in the document.
NextSibling { get; } Gets the node immediately following this node.
NodeChangingCallback { get; set; } Called when a node is inserted or removed in the document.
abstract NodeType { get; } Gets the type of this node.
PageColor { get; set; } Gets or sets the page color of the document. This property is a simpler version of BackgroundShape.
ParentNode { get; } Gets the immediate parent of this node.
PreviousSibling { get; } Gets the node immediately preceding this node.
Range { get; } Returns a Range object that represents the portion of a document that is contained in this node.
ResourceLoadingCallback { get; set; } Allows to control how external resources are loaded.
Styles { get; } Returns a collection of styles defined in the document.
WarningCallback { get; set; } Called during various document processing procedures when an issue is detected that might result in data or formatting fidelity loss.


Name Description
abstract Accept(DocumentVisitor) Accepts a visitor.
AppendChild(Node) Adds the specified node to the end of the list of child nodes for this node.
Clone(bool) Creates a duplicate of the node.
CreateNavigator() Reserved for system use. IXPathNavigable.
GetAncestor(NodeType) Gets the first ancestor of the specified NodeType.
GetAncestor(Type) Gets the first ancestor of the specified object type.
GetChild(NodeType, int, bool) Returns an Nth child node that matches the specified type.
GetChildNodes(NodeType, bool) Returns a live collection of child nodes that match the specified type.
GetEnumerator() Provides support for the for each style iteration over the child nodes of this node.
override GetText() Gets the text of this node and of all its children.
ImportNode(Node, bool) Imports a node from another document to the current document.
ImportNode(Node, bool, ImportFormatMode) Imports a node from another document to the current document with an option to control formatting.
IndexOf(Node) Returns the index of the specified child node in the child node array.
InsertAfter(Node, Node) Inserts the specified node immediately after the specified reference node.
InsertBefore(Node, Node) Inserts the specified node immediately before the specified reference node.
NextPreOrder(Node) Gets next node according to the pre-order tree traversal algorithm.
PrependChild(Node) Adds the specified node to the beginning of the list of child nodes for this node.
PreviousPreOrder(Node) Gets the previous node according to the pre-order tree traversal algorithm.
Remove() Removes itself from the parent.
RemoveAllChildren() Removes all the child nodes of the current node.
RemoveChild(Node) Removes the specified child node.
RemoveSmartTags() Removes all SmartTag descendant nodes of the current node.
SelectNodes(string) Selects a list of nodes matching the XPath expression.
SelectSingleNode(string) Selects the first Node that matches the XPath expression.
ToString(SaveFormat) Exports the content of the node into a string in the specified format.
ToString(SaveOptions) Exports the content of the node into a string using the specified save options.


Aspose.Words represents a Word document as a tree of nodes. DocumentBase is a root node of the tree that contains all other nodes of the document.

DocumentBase also stores document-wide information such as Styles and Lists that the tree nodes might refer to.


Shows how to initialize the subclasses of DocumentBase.

Document doc = new Document();

Assert.AreEqual(typeof(DocumentBase), doc.GetType().BaseType);

GlossaryDocument glossaryDoc = new GlossaryDocument();
doc.GlossaryDocument = glossaryDoc;

Assert.AreEqual(typeof(DocumentBase), glossaryDoc.GetType().BaseType);

See Also