VegaRise.NET
Back to DOM

TextClass

Definition

Namespace
DOM.Elements.TextElements
Assembly
DOM.dll

Represents a text run within the document model.

Remarks

A node holds the smallest unit of document content: a literal string of characters plus an optional character-level style. It corresponds to a <w:r> element in WordprocessingML and to a <span> in HTML. Text Text runs are typically created by calling on a or by instantiating a directly. They support search and replace operations with optional regular-expression, whole-word, and case-sensitivity behaviour via and . AddText(string) Paragraph Text Find(string, RegexOptions?, bool, bool) Replace(string, string, RegexOptions?, bool, bool)

Examples

csharp
1// 1. Simple text run
2var t = new Text("Hello world");
3
csharp
1// 2. Styled text run
2var t = new Text("Important")
3{
4 Style = new TextStyle
5 {
6 Font = new Font
7 {
8 Latin = new FontPart { FontName = "Calibri", Size = new FontSize(12), IsBold = true },
9 Color = Color.Red,
10 }
11 }
12};
13
csharp
1// 3. Find and replace (case-insensitive)
2var t = new Text("Hello world! Welcome to the world.");
3t.Replace("world", "universe");
4// Content == "Hello universe! Welcome to the universe."
5
csharp
1// 4. Regex replace and find indices
2using System.Text.RegularExpressions;
3var t = new Text("Order #12345 shipped on 2024-01-01.");
4t.Replace(@"\d{4}-\d{2}-\d{2}", "****-**-**");
5var indices = t.Find("Order", caseSensitive: true);
6// indices = [0]
7

Constructors

Text()

Initializes a new instance of the class with empty content. Text

Text(string text)

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

Properties

Contentstring

Gets or sets the literal textual content contained in this text run.

Gets or sets the style applied to this text run.

The style is applied per-run, so a paragraph may mix several styles by combining multiple instances with different values. Text Style

Methods

Finds all occurrences of the specified search text within the current text content. Supports optional regular expression behavior, whole-word matching, and case-sensitivity controls. Returns a list of character indices where matches occur.

Replaces occurrences of the specified search text within the current text content. Supports optional regular expression behavior, whole-word matching, and case-sensitivity controls.

VegaRise.NET

Sign In

Welcome back. Please sign in to your account.

Forgot password?
or

Don't have an account? Create an account

By signing in, you agree to our Terms of Service and Privacy Policy.