Click or drag to resize

Run Class

Represents a run of characters with the same character formatting.
Inheritance Hierarchy

Namespace:  SautinSoft.Document
Assembly:  SautinSoft.Document (in SautinSoft.Document.dll) Version: 3.8.6.28 (3.8.6.28)
Syntax
public sealed class Run : Inline

The Run type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleRun(DocumentCore)
Initializes a new instance of the Run class.
Public methodCode exampleRun(DocumentCore, Char)
Initializes a new instance of the Run class.
Public methodCode exampleRun(DocumentCore, String)
Initializes a new instance of the Run class.
Public methodCode exampleRun(DocumentCore, Char, CharacterFormat)
Initializes a new instance of the Run class.
Public methodCode exampleRun(DocumentCore, String, CharacterFormat)
Initializes a new instance of the Run class.
Top
Properties
  NameDescription
Public propertyCode exampleCharacterFormat
Gets or sets the character format.
Public propertyContent
Gets the ContentRange of the current element.
(Inherited from Element.)
Public propertyDocument
Gets the owner document.
(Inherited from Element.)
Public propertyElementType
Gets the ElementType of this element instance.
(Overrides ElementElementType.)
Public propertyNextSibling
Gets the next Element sibling.
(Inherited from Element.)
Public propertyParent
Gets the parent of this element instance.
(Inherited from Element.)
Public propertyParentCollection
Gets the InlineCollection that contains this Inline instance.
(Inherited from Inline.)
Public propertyPreviuosSibling
Gets the previous Element sibling.
(Inherited from Element.)
Public propertyCode exampleText
Gets or sets the text of the run.
Top
Methods
  NameDescription
Public methodClone
Clones this element instance.
Public methodCode exampleClone(Boolean)
Clones this element instance.
(Inherited from Inline.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodCode exampleGetChildElements(Boolean)
Gets the child elements.
(Inherited from Element.)
Public methodCode exampleGetChildElements(Boolean, ElementType)
Gets the child elements filtered by ElementType.
(Inherited from Element.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Examples
Get all Text (Run objects) from DOCX document and show it on Console using C#
using System;
using System.IO;
using System.Linq;
using SautinSoft.Document;

namespace Example
{
    class Program
    {
        static void Main(string[] args)
        {
            GetText();
        }
        /// <summary>
        /// Get all Text (Run objects) from DOCX document and show it on Console.
        /// </summary>
        /// <remarks>
        /// Details: https://sautinsoft.com/products/document/examples/get-text-from-docx-document-net-csharp-vb.php
        /// </remarks>
        static void GetText()
        {
            string filePath = @"..\..\example.docx";
            DocumentCore dc = DocumentCore.Load(filePath);

            // Get all Run elements from document.
            foreach (Run run in dc.GetChildElements(true,ElementType.Run))
            {
                Console.WriteLine(run.Text);
            }

            Console.ReadKey();
        }
    }
}
Get all Text (Run objects) from DOCX document and show it on Console using VB.Net
Imports System
Imports System.IO
Imports SautinSoft.Document

Module Sample
    Sub Main()
        GetText()
    End Sub

    ''' <summary>
    ''' Get all Text (Run objects) from DOCX document and show it on Console.
    ''' </summary>
    ''' <remarks>
    ''' Details: https://sautinsoft.com/products/document/examples/get-text-from-docx-document-net-csharp-vb.php
    ''' </remarks>
    Sub GetText()
        Dim filePath As String = "..\example.docx"
        Dim dc As DocumentCore = DocumentCore.Load(filePath)

        ' Get all Run elements from document.
        For Each run As Run In dc.GetChildElements(True, ElementType.Run)
            Console.WriteLine(run.Text)
        Next run
        Console.ReadKey()
    End Sub
End Module
See Also