Class FormattedText
A rich-text block that can be drawn onto a page. Supports font, size, style, color, alignment and optional line-wrapping.
Implements
Inherited Members
Namespace: DRIT.Pdf.Content
Assembly: DRIT.Pdf.dll
Syntax
public sealed class FormattedText : IDisposable
Properties
Color
Gets or sets the text color. Default is Black.
Declaration
public PdfColor Color { get; set; }
Property Value
| Type | Description |
|---|---|
| PdfColor |
FontFamily
Gets or sets the font family. Default is Helvetica.
Declaration
public PdfFontFamily? FontFamily { get; set; }
Property Value
| Type | Description |
|---|---|
| PdfFontFamily |
FontSize
Gets or sets the font size in points. Default is 12.0.
Declaration
public double FontSize { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
FontStyle
Gets or sets the font style. Default is Normal.
Declaration
public PdfFontStyle FontStyle { get; set; }
Property Value
| Type | Description |
|---|---|
| PdfFontStyle |
FontWeight
Gets or sets the font weight. Default is Normal.
Declaration
public PdfFontWeight FontWeight { get; set; }
Property Value
| Type | Description |
|---|---|
| PdfFontWeight |
Height
Gets the measured height of the text block in points.
Declaration
public double Height { get; }
Property Value
| Type | Description |
|---|---|
| double |
MaxTextWidth
Gets or sets the maximum text width for line wrapping. Default is 0 (no limit).
Declaration
public double MaxTextWidth { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
MaxTextWidths
Gets or sets per-column maximum widths for multi-column text layout.
Declaration
public double[]? MaxTextWidths { get; set; }
Property Value
| Type | Description |
|---|---|
| double[] |
Opacity
Gets or sets the text opacity (0.0 to 1.0). Default is 1.0.
Declaration
public double Opacity { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
TextAlignment
Gets or sets the horizontal text alignment. Default is Left.
Declaration
public TextAlignment TextAlignment { get; set; }
Property Value
| Type | Description |
|---|---|
| TextAlignment |
Width
Gets the measured width of the text block in points.
Declaration
public double Width { get; }
Property Value
| Type | Description |
|---|---|
| double |
Methods
Append(string)
Append text using the current formatting state.
Declaration
public FormattedText Append(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text |
Returns
| Type | Description |
|---|---|
| FormattedText |
AppendLine(string)
Append text followed by a newline.
Declaration
public FormattedText AppendLine(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text |
Returns
| Type | Description |
|---|---|
| FormattedText |
Clear()
Clear all runs (but preserve font/color settings).
Declaration
public void Clear()
Dispose()
Releases resources used by this text block.
Declaration
public void Dispose()