Class TextContent
Represents a single run of text within a text content element.
Implements
Inherited Members
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 |
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. |