GemBox.Pdf
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    PdfFormattedText Class

    Namespace:
    GemBox.Pdf.Content
    Assembly:
    GemBox.Pdf.dll

    Provides control for drawing text in PDF document.

    • C#
    • VB.NET
    public sealed class PdfFormattedText : IDisposable
    Public NotInheritable Class PdfFormattedText
        Implements IDisposable
    Inheritance:
    System.Object
    PdfFormattedText
    Implements
    System.IDisposable

    Properties

    Color

    Gets or sets the color for the characters appended next to the PdfFormattedText object.

    • C#
    • VB.NET
    public PdfColor Color { get; set; }
    Public Property Color As PdfColor
    Property Value
    PdfColor

    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.

    • C#
    • VB.NET
    public PdfFont Font { get; set; }
    Public Property Font As PdfFont
    Property Value
    PdfFont

    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.

    • C#
    • VB.NET
    public PdfFontFace FontFace { get; set; }
    Public Property FontFace As PdfFontFace
    Property Value
    PdfFontFace

    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.

    • C#
    • VB.NET
    public PdfFontFamily FontFamily { get; set; }
    Public Property FontFamily As PdfFontFamily
    Property Value
    PdfFontFamily

    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.

    • C#
    • VB.NET
    public double FontSize { get; set; }
    Public Property FontSize As Double
    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.

    • C#
    • VB.NET
    public PdfFontStretch FontStretch { get; set; }
    Public Property FontStretch As PdfFontStretch
    Property Value
    PdfFontStretch

    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.

    • C#
    • VB.NET
    public PdfFontStyle FontStyle { get; set; }
    Public Property FontStyle As PdfFontStyle
    Property Value
    PdfFontStyle

    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.

    • C#
    • VB.NET
    public PdfFontWeight FontWeight { get; set; }
    Public Property FontWeight As PdfFontWeight
    Property Value
    PdfFontWeight

    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.

    • C#
    • VB.NET
    public double Height { get; }
    Public ReadOnly Property Height As Double
    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.

    • C#
    • VB.NET
    public PdfLanguage Language { get; set; }
    Public Property Language As PdfLanguage
    Property Value
    PdfLanguage

    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.

    • C#
    • VB.NET
    public int Length { get; }
    Public ReadOnly Property Length As Integer
    Property Value
    System.Int32

    The total number of PdfFormattedText positions.

    LineHeight

    Gets or sets the line height, or line spacing, between lines of text.

    • C#
    • VB.NET
    public double LineHeight { get; set; }
    Public Property LineHeight As Double
    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.

    • C#
    • VB.NET
    public double MaxTextWidth { get; set; }
    Public Property MaxTextWidth As Double
    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.

    • C#
    • VB.NET
    public double[] MaxTextWidths { get; set; }
    Public Property MaxTextWidths As Double()
    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.

    • C#
    • VB.NET
    public double Opacity { get; set; }
    Public Property Opacity As Double
    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.

    • C#
    • VB.NET
    public PdfTextDecoration Strikethrough { get; set; }
    Public Property Strikethrough As PdfTextDecoration
    Property Value
    PdfTextDecoration

    The strikethrough for the characters appended next to the PdfFormattedText object.

    TextAlignment

    Gets or sets the alignment of text within a PdfFormattedText object.

    • C#
    • VB.NET
    public PdfTextAlignment TextAlignment { get; set; }
    Public Property TextAlignment As PdfTextAlignment
    Property Value
    PdfTextAlignment

    One of the PdfTextAlignment values that specifies the alignment of text within a PdfFormattedText object.

    TextFormattingMode

    Gets or sets the text formatting mode.

    • C#
    • VB.NET
    public PdfTextFormattingMode TextFormattingMode { get; set; }
    Public Property TextFormattingMode As PdfTextFormattingMode
    Property Value
    PdfTextFormattingMode

    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.

    • C#
    • VB.NET
    public PdfTextDecoration Underline { get; set; }
    Public Property Underline As PdfTextDecoration
    Property Value
    PdfTextDecoration

    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.

    • C#
    • VB.NET
    public double Width { get; }
    Public ReadOnly Property Width As Double
    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.

    • C#
    • VB.NET
    public PdfFormattedText Append(string value)
    Public Function Append(value As String) As PdfFormattedText
    Parameters
    value
    System.String

    The string to append.

    Returns
    PdfFormattedText

    A reference to this PdfFormattedText instance.

    AppendLine()

    Appends the line terminator to the end of the current PdfFormattedText object.

    • C#
    • VB.NET
    public PdfFormattedText AppendLine()
    Public Function AppendLine As PdfFormattedText
    Returns
    PdfFormattedText

    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.

    • C#
    • VB.NET
    public PdfFormattedText AppendLine(string value)
    Public Function AppendLine(value As String) As PdfFormattedText
    Parameters
    value
    System.String

    The string to append.

    Returns
    PdfFormattedText

    A reference to this PdfFormattedText instance.

    Clear()

    Removes all characters from the current PdfFormattedText instance.

    • C#
    • VB.NET
    public PdfFormattedText Clear()
    Public Function Clear As PdfFormattedText
    Returns
    PdfFormattedText

    A reference to this PdfFormattedText instance.

    Dispose()

    Releases all managed and unmanaged resources used by the PdfFormattedText object.

    • C#
    • VB.NET
    public void Dispose()
    Public Sub Dispose

    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.

    • C#
    • VB.NET
    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
    PdfFormattedTextLine

    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.

    • C#
    • VB.NET
    public override string ToString()
    Public Overrides Function ToString As String
    Returns
    System.String

    A string whose value is the same as this instance.

    Overrides
    System.Object.ToString()

    Implements

    System.IDisposable

    Examples

    Writing example
    Text alignment and positioning example
    Text from complex scripts example
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.