PdfFormattedText Class
Provides control for drawing text in PDF document.
public sealed class PdfFormattedText : IDisposable
Public NotInheritable Class PdfFormattedText
Implements IDisposable
- Inheritance:
- System.ObjectPdfFormattedText
Implements
Properties
Color
Gets or sets the color for the characters appended next to the PdfFormattedText object.
Property Value
The color for the characters appended next to the PdfFormattedText object.
Exceptions
- System.ArgumentException
The value's Space is not device color space (DeviceGray, DeviceRGB, or DeviceCMYK).
Font
Gets or sets the font for the characters appended next to the PdfFormattedText object.
Property Value
The font for the characters appended next to the PdfFormattedText object.
Exceptions
- System.ArgumentNullException
Value is null.
FontFace
Gets or sets the font face for the characters appended next to the PdfFormattedText object.
Property Value
The font face for the characters appended next to the PdfFormattedText object.
Exceptions
- System.ArgumentNullException
Value is null.
FontFamily
Gets or sets the font family for the characters appended next to the PdfFormattedText object.
Property Value
The font family for the characters appended next to the PdfFormattedText object.
Exceptions
- System.ArgumentNullException
Value is null.
FontSize
Gets or sets the font size, in points (1/72 inch per point), for the characters appended next to the PdfFormattedText object.
Property Value
- System.Double
The font size, in points (1/72 inch per point), for the characters appended next to the PdfFormattedText object.
Exceptions
- System.ArgumentOutOfRangeException
Value is less than or equal to 0.
- System.ArgumentException
Value is either System.Double.NaN, System.Double.NegativeInfinity or System.Double.PositiveInfinity.
FontStretch
Gets or sets the font stretch for the characters appended next to the PdfFormattedText object.
public PdfFontStretch FontStretch { get; set; }
Public Property FontStretch As PdfFontStretch
Property Value
The font stretch for the characters appended next to the PdfFormattedText object.
FontStyle
Gets or sets the font style for the characters appended next to the PdfFormattedText object.
Property Value
The font style for the characters appended next to the PdfFormattedText object.
FontWeight
Gets or sets the font weight for the characters appended next to the PdfFormattedText object.
Property Value
The font weight for the characters appended next to the PdfFormattedText object.
Height
Gets the distance from the top of the first line to the bottom of the last line of the PdfFormattedText object.
Property Value
- System.Double
The distance from the top of the first line to the bottom of the last line, provided in points (1/72 inch per point).
Language
Gets or sets the language for the characters appended next to the PdfFormattedText object.
Property Value
The language for the characters appended next to the PdfFormattedText object.
Exceptions
- System.ArgumentNullException
Value is null.
Length
Gets the total number of PdfFormattedText positions.
Should be used with the FormatLine(Int32, Double) method and the Length property.
Property Value
- System.Int32
The total number of PdfFormattedText positions.
LineHeight
Gets or sets the line height, or line spacing, between lines of text.
Property Value
- System.Double
The line spacing between lines of text, provided in points (1/72 inch per point).
Remarks
The default line height is automatically calculated, and is based on the Font.
Exceptions
- System.ArgumentOutOfRangeException
Value is less than zero.
MaxTextWidth
Gets or sets the maximum text width for a line of text.
Property Value
- System.Double
The maximum text width for a line of text, provided in points (1/72 inch per point).
Exceptions
- System.ArgumentOutOfRangeException
Value is less than zero.
MaxTextWidths
Gets or sets the array of maximum text widths within the PdfFormattedText, on a per-line basis. Each element in the array represents the maximum text width of sequential lines of text.
Property Value
- System.Double[]
The array of maximum text widths, each width provided in points (1/72 inch per point).
Remarks
If the text lines exceed the number of elements in the array, the last value in the array is used for the remaining lines.
Exceptions
- System.ArgumentNullException
Value is null or empty array.
Opacity
Gets or sets the opacity for the characters appended next to the PdfFormattedText object.
Property Value
- System.Double
The opacity for the characters appended next to the PdfFormattedText object.
Exceptions
- System.ArgumentOutOfRangeException
Value is not between 0 and 1 inclusive.
Strikethrough
Gets or sets the strikethrough for the characters appended next to the PdfFormattedText object.
public PdfTextDecoration Strikethrough { get; set; }
Public Property Strikethrough As PdfTextDecoration
Property Value
The strikethrough for the characters appended next to the PdfFormattedText object.
TextAlignment
Gets or sets the alignment of text within a PdfFormattedText object.
public PdfTextAlignment TextAlignment { get; set; }
Public Property TextAlignment As PdfTextAlignment
Property Value
One of the PdfTextAlignment values that specifies the alignment of text within a PdfFormattedText object.
TextFormattingMode
Gets or sets the text formatting mode.
public PdfTextFormattingMode TextFormattingMode { get; set; }
Public Property TextFormattingMode As PdfTextFormattingMode
Property Value
The PdfTextFormattingMode that specifies the text layout for the PdfFormattedText.
Exceptions
- System.ObjectDisposedException
PdfFormattedText is disposed.
- System.NotSupportedException
The specified PdfTextFormattingMode is not supported.
Underline
Gets or sets the underline for the characters appended next to the PdfFormattedText object.
public PdfTextDecoration Underline { get; set; }
Public Property Underline As PdfTextDecoration
Property Value
The underline for the characters appended next to the PdfFormattedText object.
Width
Gets the width between the leading and trailing alignment points of a line, excluding any trailing white-space characters.
Property Value
- System.Double
The width between the leading and trailing alignment points of a line, excluding any trailing white-space characters. Provided in points (1/72 inch per point).
Remarks
For multi-line text, the longest line is used for the Width value.
Methods
Append(String)
Appends the specified string to this PdfFormattedText instance.
public PdfFormattedText Append(string value)
Public Function Append(value As String) As PdfFormattedText
Parameters
value
- System.String
The string to append.
Returns
A reference to this PdfFormattedText instance.
AppendLine()
Appends the line terminator to the end of the current PdfFormattedText object.
Returns
A reference to this PdfFormattedText instance.
AppendLine(String)
Appends the specified string followed by the line terminator to the end of the current PdfFormattedText object.
public PdfFormattedText AppendLine(string value)
Public Function AppendLine(value As String) As PdfFormattedText
Parameters
value
- System.String
The string to append.
Returns
A reference to this PdfFormattedText instance.
Clear()
Removes all characters from the current PdfFormattedText instance.
Returns
A reference to this PdfFormattedText instance.
Dispose()
Releases all managed and unmanaged resources used by the PdfFormattedText object.
FormatLine(Int32, Double)
Creates a PdfFormattedTextLine that starts with the specified character index and is of the specified maximum width.
This method allows incremental breaking of a PdfFormattedText to PdfFormattedTextLines.
It is useful in the following scenarios:
- The PdfFormattedText might contain a lot of text that would be broken in a lot of lines and you only want to draw some of those lines.
- The PdfFormattedText might not fit to the available height. Then each line should be formatted and, if it fits to the available height, drawn.
- The PdfFormattedText might have lines that should have different
maxLineWidth
or be drawn in a custom location (for example, text contained in a non-rectangular area).
To format the next PdfFormattedTextLine, increment the firstCharIndex
by Length of the current PdfFormattedTextLine, until firstCharIndex
is greater than or equal to the Length.
Use method DrawText(PdfFormattedTextLine, PdfPoint) to draw the PdfFormattedTextLine.
public PdfFormattedTextLine FormatLine(int firstCharIndex, double maxLineWidth)
Public Function FormatLine(firstCharIndex As Integer, maxLineWidth As Double) As PdfFormattedTextLine
Parameters
firstCharIndex
- System.Int32
The character index of the starting character in the PdfFormattedTextLine.
maxLineWidth
- System.Double
The maximum width of a PdfFormattedTextLine, provided in points (1/72 inch per point).
Returns
A PdfFormattedTextLine value that represents a line of PdfFormattedText that can be drawn with DrawText(PdfFormattedTextLine, PdfPoint) method.
Exceptions
- System.ArgumentOutOfRangeException
firstCharIndex
is less than zero or greater than or equal to the Length or maxLineWidth
is less than zero.
ToString()
Converts the value of this instance to a System.String.
Returns
- System.String
A string whose value is the same as this instance.