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

# TextState

## Overview

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

Text formatting state.

This class provides 10 methods for working with TextState objects in .NET programs.
Available methods include: `ApplyChangesFrom`, `MeasureHeight`, `MeasureString`, `TextState`.
All public members are accessible to any .NET application after installing the Aspose.PDF FOSS for .NET package.
Properties: `BackgroundColor`, `CharacterSpacing`, `CoordinateOrigin`, `Font`, `FontData`, `FontName`, and 25 more.

## Properties

| Name | Type | Access | Description |
|------|------|--------|-------------|
| `FontName` | `string?` | Read/Write | Gets or sets the font name. |
| `TextHeight` | `float` | Read | Approximate text height in points; approximates the glyph-bounding-box-derived height by returning the font size (typical ratio between FontSize and rendered text height is close enough for the layout math callers use this for). |
| `FontSize` | `float` | Read/Write | Gets or sets the font size. |
| `ForegroundColor` | `Color?` | Read/Write | Gets or sets the foreground color. |
| `StrokingColor` | `Color?` | Read/Write | Stroking (outline) color of the text. |
| `CoordinateOrigin` | `CoordinateOrigin` | Read/Write | Whether text positioning treats Y as the baseline or the descender. |
| `BackgroundColor` | `Color?` | Read/Write | Gets or sets the background color. |
| `IsBold` | `bool` | Read/Write | Whether the font is bold. |
| `IsItalic` | `bool` | Read/Write | Whether the font is italic. |
| `FontStyle` | `FontStyles` | Read/Write | Font style flags (Bold, Italic, etc.). |
| `Underline` | `bool` | Read/Write | Whether the text is underlined (alias for IsUnderline). |
| `IsUnderline` | `bool` | Read/Write | Whether the text is underlined. |
| `IsStrikeOut` | `bool` | Read/Write | Whether the text has strikethrough. |
| `StrikeOut` | `bool` | Read/Write | Alias for IsStrikeOut. |
| `IsSuperscript` | `bool` | Read/Write | Whether the text is superscript. |
| `Superscript` | `bool` | Read/Write | Alias for IsSuperscript. |
| `IsSubscript` | `bool` | Read/Write | Whether the text is subscript. |
| `Subscript` | `bool` | Read/Write | Alias for IsSubscript. |
| `CharacterSpacing` | `float` | Read/Write | Character spacing in text space units. |
| `WordSpacing` | `float` | Read/Write | Word spacing in text space units. |
| `HorizontalScaling` | `float` | Read/Write | Horizontal scaling percentage (default 100). |
| `LineSpacing` | `float` | Read/Write | Line spacing (leading) in text space units. |
| `TabTag` | `string` | Read | String token inserted into the rendered text in place of a tab character. |
| `HorizontalAlignment` | `HorizontalAlignment` | Read/Write | Horizontal alignment of the text. |
| `RenderingMode` | `TextRenderingMode` | Read/Write | Text rendering mode (Tr operator). |
| `Invisible` | `bool` | Read/Write | Whether this text fragment is invisible (rendering mode 3). |
| `TextRise` | `double` | Read/Write | Text rise (superscript/subscript offset). |
| `Rotation` | `double` | Read/Write | Text rotation angle in degrees. |
| `Font` | `Font?` | Read/Write | Gets or sets the font. |
| `FontData` | `FontData?` | Read/Write | External font data for embedding (set via FontRepository.OpenFont). |
| `FormattingOptions` | `TextFormattingOptions` | Read/Write | Text formatting options (WordWrapMode, LineSpacingMode, etc.). |

## Methods

| Signature | Description |
|-----------|-------------|
| `TextState()` | Calls TextState on this TextState instance. |
| `TextState(fontSize: double)` | Calls TextState(fontSize) on this TextState instance. |
| `TextState(fontFamily: string)` | Calls TextState(fontFamily) on this TextState instance. |
| `TextState(fontFamily: string, fontSize: double)` | Calls TextState(fontFamily, fontSize) on this TextState instance. |
| `TextState(fontFamily: string, bold: bool, italic: bool)` | Calls TextState(fontFamily, bold, italic) on this TextState instance. |
| `TextState(foregroundColor: System.Drawing.Color)` | Calls TextState(foregroundColor) on this TextState instance. |
| `TextState(foregroundColor: System.Drawing.Color, fontSize: double)` | Calls TextState(foregroundColor, fontSize) on this TextState instance. |
| `MeasureString(str: string)` | Rough text-width estimate at the current font/size. |
| `MeasureHeight(character: char)` | Rough character-height estimate at the current font/size. |
| `ApplyChangesFrom(textState: TextState)` | Copy every public formatting property from other into this state (leaving owner linkage intact). |

## See Also

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