Run Class |
Namespace: Aspose.Words
The Run type exposes the following members.
Name | Description | |
---|---|---|
![]() ![]() | Run(DocumentBase) |
Initializes a new instance of the Run class.
|
![]() ![]() | Run(DocumentBase, String) |
Initializes a new instance of the Run class.
|
Name | Description | |
---|---|---|
![]() ![]() | Document |
Gets the document to which this node belongs.
(Inherited from Node.) |
![]() ![]() | Font |
Provides access to the font formatting of this object.
(Inherited from Inline.) |
![]() ![]() | IsComposite |
Returns true if this node can contain other nodes.
(Inherited from Node.) |
![]() ![]() | IsDeleteRevision |
Returns true if this object was deleted in Microsoft Word while change tracking was enabled.
(Inherited from Inline.) |
![]() ![]() | IsFormatRevision |
Returns true if formatting of the object was changed in Microsoft Word while change tracking was enabled.
(Inherited from Inline.) |
![]() ![]() | IsInsertRevision |
Returns true if this object was inserted in Microsoft Word while change tracking was enabled.
(Inherited from Inline.) |
![]() ![]() | IsMoveFromRevision |
Returns true if this object was moved (deleted) in Microsoft Word while change tracking was enabled.
(Inherited from Inline.) |
![]() ![]() | IsMoveToRevision |
Returns true if this object was moved (inserted) in Microsoft Word while change tracking was enabled.
(Inherited from Inline.) |
![]() ![]() | NextSibling |
Gets the node immediately following this node.
(Inherited from Node.) |
![]() ![]() | NodeType |
Returns NodeType.Run.
(Overrides NodeNodeType.) |
![]() ![]() | ParentNode |
Gets the immediate parent of this node.
(Inherited from Node.) |
![]() ![]() | ParentParagraph |
Retrieves the parent Paragraph of this node.
(Inherited from Inline.) |
![]() ![]() | 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.) |
![]() ![]() | Text |
Gets or sets the text of the run.
|
Name | Description | |
---|---|---|
![]() ![]() | Accept |
Accepts a visitor.
(Overrides NodeAccept(DocumentVisitor).) |
![]() ![]() | Clone | (Inherited from Node.) |
![]() | 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.) |
![]() | GetHashCode | (Inherited from Object.) |
![]() ![]() | GetText |
Gets the text of the run.
(Overrides NodeGetText.) |
![]() | GetType | (Inherited from Object.) |
![]() ![]() | NextPreOrder |
Gets next node according to the pre-order tree traversal algorithm.
(Inherited from Node.) |
![]() ![]() | 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.) |
![]() | 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.) |
All text of the document is stored in runs of text.
Run can only be a child of Paragraph.
// Create an empty document. It contains one empty paragraph Document doc = new Document(); // Create a new run of text Run run = new Run(doc, "Hello"); // Specify character formatting for the run of text Aspose.Words.Font f = run.Font; f.Name = "Courier New"; f.Size = 36; f.HighlightColor = Color.Yellow; // Append the run of text to the end of the first paragraph // in the body of the first section of the document doc.FirstSection.Body.FirstParagraph.AppendChild(run);
Document doc = new Document(MyDir + "Rendering.docx"); // Select all runs in the document NodeCollection runs = doc.GetChildNodes(NodeType.Run, true); // Use a hashtable so we will keep only unique font names Hashtable fontNames = new Hashtable(); foreach (Run run in runs.OfType<Run>()) { // This adds an entry into the hashtable // The key is the font name. The value is null, we don't need the value fontNames[run.Font.Name] = null; } // There are two fonts used in this document Console.WriteLine("Font Count: " + fontNames.Count);
// 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");