Body Class |
Namespace: Aspose.Words
The Body type exposes the following members.
| Name | Description | |
|---|---|---|
| Body |
Initializes a new instance of the Body class.
|
| Name | Description | |
|---|---|---|
| ChildNodes |
Gets all immediate child nodes of this node.
(Inherited from CompositeNode.) | |
| Count |
Gets the number of immediate children of this node.
(Inherited from CompositeNode.) | |
| Document |
Gets the document to which this node belongs.
(Inherited from Node.) | |
| FirstChild |
Gets the first child of the node.
(Inherited from CompositeNode.) | |
| FirstParagraph |
Gets the first paragraph in the story.
(Inherited from Story.) | |
| HasChildNodes |
Returns true if this node has any child nodes.
(Inherited from CompositeNode.) | |
| IsComposite |
Returns true as this node can have child nodes.
(Inherited from CompositeNode.) | |
| LastChild |
Gets the last child of the node.
(Inherited from CompositeNode.) | |
| LastParagraph |
Gets the last paragraph in the story.
(Inherited from Story.) | |
| NextSibling |
Gets the node immediately following this node.
(Inherited from Node.) | |
| NodeType |
Returns NodeType.Body.
(Overrides NodeNodeType.) | |
| Paragraphs |
Gets a collection of paragraphs that are immediate children of the story.
(Inherited from Story.) | |
| ParentNode |
Gets the immediate parent of this node.
(Inherited from Node.) | |
| ParentSection |
Gets the parent section of this story.
| |
| PreviousSibling |
Gets the node immediately preceding this node.
(Inherited from Node.) | |
| Range |
Returns a Range object that represents the portion of a document that is contained in this node.
(Inherited from Node.) | |
| StoryType |
Gets the type of this story.
(Inherited from Story.) | |
| Tables |
Gets a collection of tables that are immediate children of the story.
(Inherited from Story.) |
| Name | Description | |
|---|---|---|
| Accept |
Accepts a visitor.
(Overrides NodeAccept(DocumentVisitor).) | |
| AppendChild |
Adds the specified node to the end of the list of child nodes for this node.
(Inherited from CompositeNode.) | |
| AppendParagraph |
A shortcut method that creates a Paragraph object with optional text and appends it to the end of this object.
(Inherited from Story.) | |
| Clone | (Inherited from Node.) | |
| DeleteShapes |
Deletes all shapes from the text of this story.
(Inherited from Story.) | |
| EnsureMinimum |
If the last child is not a paragraph, creates and appends one empty paragraph.
| |
| Equals | (Inherited from Object.) | |
| GetAncestor(Type) |
Gets the first ancestor of the specified object type.
(Inherited from Node.) | |
| GetAncestor(NodeType) |
Gets the first ancestor of the specified NodeType.
(Inherited from Node.) | |
| GetChild |
Returns an Nth child node that matches the specified type.
(Inherited from CompositeNode.) | |
| GetChildNodes |
Returns a live collection of child nodes that match the specified type.
(Inherited from CompositeNode.) | |
| GetEnumerator |
Provides support for the for each style iteration over the child nodes of this node.
(Inherited from CompositeNode.) | |
| GetHashCode | (Inherited from Object.) | |
| GetText |
Gets the text of this node and of all its children.
(Inherited from CompositeNode.) | |
| GetType | (Inherited from Object.) | |
| IndexOf |
Returns the index of the specified child node in the child node array.
(Inherited from CompositeNode.) | |
| InsertAfter |
Inserts the specified node immediately after the specified reference node.
(Inherited from CompositeNode.) | |
| InsertBefore |
Inserts the specified node immediately before the specified reference node.
(Inherited from CompositeNode.) | |
| NextPreOrder |
Gets next node according to the pre-order tree traversal algorithm.
(Inherited from Node.) | |
| PrependChild |
Adds the specified node to the beginning of the list of child nodes for this node.
(Inherited from CompositeNode.) | |
| PreviousPreOrder |
Gets the previous node according to the pre-order tree traversal algorithm.
(Inherited from Node.) | |
| Remove |
Removes itself from the parent.
(Inherited from Node.) | |
| RemoveAllChildren |
Removes all the child nodes of the current node.
(Inherited from CompositeNode.) | |
| RemoveChild |
Removes the specified child node.
(Inherited from CompositeNode.) | |
| RemoveSmartTags |
Removes all SmartTag descendant nodes of the current node.
(Inherited from CompositeNode.) | |
| SelectNodes |
Selects a list of nodes matching the XPath expression.
(Inherited from CompositeNode.) | |
| SelectSingleNode |
Selects the first Node that matches the XPath expression.
(Inherited from CompositeNode.) | |
| ToString | (Inherited from Object.) | |
| ToString(SaveFormat) |
Exports the content of the node into a string in the specified format.
(Inherited from Node.) | |
| ToString(SaveOptions) |
Exports the content of the node into a string using the specified save options.
(Inherited from Node.) |
Body can contain Paragraph and Table child nodes.
Body is a section-level node and can only be a child of Section. There can only be one Body in a Section.
A minimal valid Body needs to contain at least one Paragraph.
// Create an "empty" document. Note that like in Microsoft Word, // the empty document has one section, body and one paragraph in it Document doc = new Document(); // This truly makes the document empty. No sections (not possible in Microsoft Word) doc.RemoveAllChildren(); // Create a new section node // Note that the section has not yet been added to the document, // but we have to specify the parent document Section section = new Section(doc); // Append the section to the document doc.AppendChild(section); // Lets set some properties for the section section.PageSetup.SectionStart = SectionStart.NewPage; section.PageSetup.PaperSize = PaperSize.Letter; // The section that we created is empty, lets populate it. The section needs at least the Body node Body body = new Body(doc); section.AppendChild(body); // The body needs to have at least one paragraph // Note that the paragraph has not yet been added to the document, // but we have to specify the parent document // The parent document is needed so the paragraph can correctly work // with styles and other document-wide information Paragraph para = new Paragraph(doc); body.AppendChild(para); // We can set some formatting for the paragraph para.ParagraphFormat.StyleName = "Heading 1"; para.ParagraphFormat.Alignment = ParagraphAlignment.Center; // So far we have one empty paragraph in the document // The document is valid and can be saved, but lets add some text before saving // Create a new run of text and add it to our paragraph Run run = new Run(doc); run.Text = "Hello World!"; run.Font.Color = Color.Red; para.AppendChild(run); // As a matter of interest, you can retrieve text of the whole document and // see that \x000c is automatically appended. \x000c is the end of section character Console.WriteLine("Hello World!\x000c"); // Save the document doc.Save(ArtifactsDir + "Section.CreateFromScratch.doc");