SubDocument

SubDocument class

Represents a SubDocument - which is a reference to an externally stored document.

public class SubDocument : Node

Properties

Name Description
CustomNodeId { get; set; } Specifies custom node identifier.
virtual Document { get; } Gets the document to which this node belongs.
virtual IsComposite { get; } Returns true if this node can contain other nodes.
NextSibling { get; } Gets the node immediately following this node.
override NodeType { get; } Returns NodeType.SubDocument
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.

Methods

Name Description
override Accept(DocumentVisitor) Accepts a visitor.
Clone(bool) Creates a duplicate of the node.
GetAncestor(NodeType) Gets the first ancestor of the specified NodeType.
GetAncestor(Type) Gets the first ancestor of the specified object type.
virtual GetText() Gets the text of this node and of all its children.
NextPreOrder(Node) Gets next node according to the pre-order tree traversal algorithm.
PreviousPreOrder(Node) Gets the previous node according to the pre-order tree traversal algorithm.
Remove() Removes itself from the parent.
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.

Remarks

In this version of Aspose.Words, SubDocument nodes do not provide public methods and properties to create or modify a subdocument. In this version you are not able to instantiate SubDocument nodes or modify existing except deleting them.

SubDocument can only be a child of Paragraph.

Examples

Shows how to access a master document’s subdocument.

Document doc = new Document(MyDir + "Master document.docx");

NodeCollection subDocuments = doc.GetChildNodes(NodeType.SubDocument, true);
// This node serves as a reference to an external document, and its contents cannot be accessed.
SubDocument subDocument = (SubDocument)subDocuments[0];

Assert.False(subDocument.IsComposite);

See Also