---
Product: Aspose.PDF
Platform: net
Page Type: reference
Canonical URL: https://reference.aspose.org/pdf/net/TextSegment
---

# TextSegment

## Overview

`TextSegment` is a class in Aspose.PDF FOSS for .NET.

A single segment within a TextFragment.

This class provides 3 methods for working with TextSegment objects in .NET programs.
Available methods include: `MyHtmlEncode`, `TextSegment`.
All public members are accessible to any .NET application after installing the Aspose.PDF FOSS for .NET package.
Properties: `BaselinePosition`, `Characters`, `EndCharIndex`, `Hyperlink`, `Position`, `Rectangle`, and 4 more.

## Properties

| Name | Type | Access | Description |
|------|------|--------|-------------|
| `Text` | `string` | Read/Write | The text of this segment. |
| `Position` | `Position?` | Read/Write | The position of this segment on the page. |
| `BaselinePosition` | `Position?` | Read/Write | Gets or sets the baseline position. |
| `TextState` | `TextState` | Read/Write | The text state (font, size, colour, etc.) for this segment. |
| `StartCharIndex` | `int` | Read | The starting character index of this segment within the source text run on the page. |
| `EndCharIndex` | `int` | Read | The ending character index of this segment within the source text run on the page. |
| `Rectangle` | `Rectangle?` | Read | The bounding rectangle of this segment on the page. |
| `Characters` | `CharInfoCollection` | Read | Per-character layout information for this segment: one CharInfo per character, in text order, populated when the segment is produced by a text absorber. |
| `Hyperlink` | `Hyperlink?` | Read/Write | Optional hyperlink associated with this segment. |
| `TextEditOptions` | `TextEditOptions` | Read/Write | Edit options applied during text replacement / font substitution. |

## Methods

| Signature | Description |
|-----------|-------------|
| `TextSegment()` | Calls TextSegment on this TextSegment instance. |
| `TextSegment(text: string)` |  |
| `MyHtmlEncode(value: string)` | HTML-encode a string by replacing &amp;, &lt;, &gt;, &quot;, and &apos; with their entity references. |

## See Also

- [Aspose.PDF for .NET — Enterprise API Reference](https://reference.aspose.com/pdf/net/)