Search Results for

    Show / Hide Table of Contents

    Class TextContent

    Represents a single run of text within a text content element.

    Inheritance
    System.Object
    ContentElement
    TextContent
    Implements
    ITextContentElement
    IWordTextObject
    IronSoftware.Abstractions.Word.IText
    IronSoftware.Abstractions.Word.IWordDocumentObject
    IronSoftware.Abstractions.IDocumentObject
    System.ICloneable
    IronSoftware.Abstractions.IJsonSerializable
    Inherited Members
    ContentElement.Replace(IWordDocumentObject)
    ContentElement.Remove()
    ContentElement.GetIndex<T>()
    ContentElement.Clone()
    ContentElement.CloneObject()
    ContentElement.Parent
    ContentElement.Status
    Namespace: IronWord.Models
    Assembly: IronWord.dll
    Syntax
    public class TextContent : ContentElement, ITextContentElement, IWordTextObject, IText, IWordDocumentObject, IDocumentObject, ICloneable, IJsonSerializable

    Constructors

    TextContent()

    Initializes a new instance of the Text class.

    Declaration
    public TextContent()

    TextContent(String)

    Initializes a new instance of the Text class with the specified text content.

    Declaration
    public TextContent(string text)
    Parameters
    Type Name Description
    System.String text

    The initial text content of the Text object.

    Properties

    Color

    The color of the text.

    Declaration
    public Color Color { get; }
    Property Value
    Type Description
    System.Drawing.Color

    Font

    Declaration
    public IFont Font { get; }
    Property Value
    Type Description
    IronSoftware.Abstractions.Word.IFont

    FontName

    Declaration
    public string FontName { get; }
    Property Value
    Type Description
    System.String

    FontSize

    Declaration
    public float FontSize { get; }
    Property Value
    Type Description
    System.Single

    FontStyle

    Declaration
    public string FontStyle { get; }
    Property Value
    Type Description
    System.String

    IsBold

    Declaration
    public bool IsBold { get; }
    Property Value
    Type Description
    System.Boolean

    IsItalic

    Declaration
    public bool IsItalic { get; }
    Property Value
    Type Description
    System.Boolean

    Style

    Style for text.

    Declaration
    public TextStyle Style { get; }
    Property Value
    Type Description
    TextStyle

    Text

    Gets or sets the text content of the Run.

    Declaration
    public string Text { get; set; }
    Property Value
    Type Description
    System.String

    Methods

    Append(TextContent)

    Appends the text content to this Text content.

    Declaration
    public TextContent Append(TextContent textContent)
    Parameters
    Type Name Description
    TextContent textContent

    The text content to append.

    Returns
    Type Description
    TextContent

    Find(String, Nullable<RegexOptions>, Boolean, Boolean)

    Finds the indices of the specified search text within the text.

    Declaration
    public List<int> Find(string searchText, Nullable<RegexOptions> regexOption = null, bool wholeWordOnly = false, bool caseSensitive = false)
    Parameters
    Type Name Description
    System.String searchText

    The text to search for.

    System.Nullable<System.Text.RegularExpressions.RegexOptions> regexOption

    Optional. The regular expression options.

    System.Boolean wholeWordOnly

    Optional. Indicates whether to match the whole word only.

    System.Boolean caseSensitive

    Optional. Indicates whether the search is case-sensitive.

    Returns
    Type Description
    System.Collections.Generic.List<System.Int32>

    A list of indices where the search text is found.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Thrown when searchText is null.

    Replace(String, String, Nullable<RegexOptions>, Boolean, Boolean)

    Finds and replaces text within this TextContentElement.

    Declaration
    public ITextContentElement Replace(string searchText, string replaceText, Nullable<RegexOptions> regexOption = null, bool wholeWordOnly = false, bool caseSensitive = false)
    Parameters
    Type Name Description
    System.String searchText

    The text to search for.

    System.String replaceText

    The text to replace with.

    System.Nullable<System.Text.RegularExpressions.RegexOptions> regexOption

    Optional regex options

    System.Boolean wholeWordOnly

    Replace whole words only

    System.Boolean caseSensitive

    Whether the search is case-sensitive

    Returns
    Type Description
    ITextContentElement

    Split(String)

    Splits the current Run into smaller Runs based on a delimiter.

    Declaration
    public List<TextContent> Split(string delimiter)
    Parameters
    Type Name Description
    System.String delimiter

    The delimiter to use for splitting.

    Returns
    Type Description
    System.Collections.Generic.List<TextContent>

    List of Run objects after split.

    ToJson()

    Declaration
    public string ToJson()
    Returns
    Type Description
    System.String

    ToString()

    Provides a textual representation of the TextContentElement.

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String

    A string representation of the element.

    Implements

    ITextContentElement
    IWordTextObject
    IronSoftware.Abstractions.Word.IText
    IronSoftware.Abstractions.Word.IWordDocumentObject
    IronSoftware.Abstractions.IDocumentObject
    System.ICloneable
    IronSoftware.Abstractions.IJsonSerializable

    Inherited members

    Replace(IWordDocumentObject)
    Remove()
    GetIndex<T>()
    Clone()
    CloneObject()
    Parent
    Status
    ☀
    ☾
    Downloads
    • Download with NuGet
    • Start for Free
    In This Article
    Back to top
    Install with NuGet
    Want to deploy IronWord to a live project for FREE?
    What’s included?
    30 days of fully-functional product
    Test and share in a live environment
    No watermarks in production
    Get your free 30-day Trial Key instantly.
    No credit card or account creation required
    Your Trial License Key has been emailed to you.
    Download IronWord free to apply
    your Trial Licenses Key
    Install with NuGet View Licenses
    Licenses from $499. Have a question? Get in touch.