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

    Show / Hide Table of Contents

    PdfTextFormat Class

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

    Represents formatting properties that only affect PDF textual content.

    • C#
    • VB.NET
    public sealed class PdfTextFormat
    Public NotInheritable Class PdfTextFormat
    Inheritance:
    System.Object
    PdfTextFormat
    Remarks

    The PdfTextFormat is applicable to PdfTextContent and PdfFormContent, and is not applicable to any other PdfVisualContentElement.

    If the PdfTextFormat is not applicable, then text-related graphics state parameters won't be written when writing the associated PdfVisualContentElement to the underlying content stream.

    Properties

    CharacterSpacing

    Gets or sets the character spacing in unscaled text space units (although it shall be subject to scaling by the HorizontalScaling parameter if the writing mode is horizontal).

    When the glyph for each character in the string is rendered, CharacterSpacing shall be added to the horizontal or vertical component of the glyph's displacement, depending on the writing mode.

    Initial value: 0.

    • C#
    • VB.NET
    public double CharacterSpacing { get; set; }
    Public Property CharacterSpacing As Double
    Property Value
    System.Double

    The character spacing in unscaled text space units.

    Exceptions
    System.ArgumentException

    Value is either System.Double.NaN, System.Double.NegativeInfinity or System.Double.PositiveInfinity.

    See Also
    PDF Specification ISO 32000-1:2008, section '9.3.2 Character Spacing'

    Font

    Gets the font.

    Initial value: null.

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

    The font.

    Remarks

    Note that the Size of the returned PdfFont for PdfTextContent is resolved from the actual font size (retrieved with GetFont(out Double) method) and the TextTransform.

    See Also
    PDF Specification ISO 32000-1:2008, section '9.3 Text State Parameters and Operators'

    HorizontalScaling

    Gets or sets the horizontal scaling that adjusts the width of glyphs by stretching or compressing them in the horizontal direction.

    Its value shall be specified as a percentage of the normal width of the glyphs, with 1.0 (100%) being the normal width. The HorizontalScaling shall apply to the horizontal coordinate in text space, independently of the writing mode. It shall affect both the glyph's shape and its horizontal displacement (that is, its displacement vector). If the writing mode is horizontal, it shall also effect the spacing parameters CharacterSpacing and WordSpacing.

    Initial value: 1.0 (100%) (normal width).

    • C#
    • VB.NET
    public double HorizontalScaling { get; set; }
    Public Property HorizontalScaling As Double
    Property Value
    System.Double

    The horizontal scaling that adjusts the width of glyphs by stretching or compressing them in the horizontal direction.

    Exceptions
    System.ArgumentException

    Value is either System.Double.NaN, System.Double.NegativeInfinity or System.Double.PositiveInfinity.

    See Also
    PDF Specification ISO 32000-1:2008, section '9.3.4 Horizontal Scaling'

    IsClipped

    Gets or sets a value indicating whether the current PDF textual content is part of the clipping area (the same as IsApplied property on PdfTextContent).

    Initial value: false.

    • C#
    • VB.NET
    public bool IsClipped { get; set; }
    Public Property IsClipped As Boolean
    Property Value
    System.Boolean

    true if the current PDF textual content is part of the clipping area; otherwise, false.

    See Also
    PDF Specification ISO 32000-1:2008, section '9.3.6 Text Rendering Mode'

    IsFilled

    Gets or sets a value indicating whether the current PDF textual content is filled (the same as IsApplied property on PdfTextContent).

    Initial value: true.

    • C#
    • VB.NET
    public bool IsFilled { get; set; }
    Public Property IsFilled As Boolean
    Property Value
    System.Boolean

    true if the current PDF textual content is filled; otherwise, false.

    See Also
    PDF Specification ISO 32000-1:2008, section '9.3.6 Text Rendering Mode'

    IsStroked

    Gets or sets a value indicating whether the current PDF textual content is stroked (the same as IsApplied property on PdfTextContent).

    Initial value: false.

    • C#
    • VB.NET
    public bool IsStroked { get; set; }
    Public Property IsStroked As Boolean
    Property Value
    System.Boolean

    true if the current PDF textual content is stroked; otherwise, false.

    See Also
    PDF Specification ISO 32000-1:2008, section '9.3.6 Text Rendering Mode'

    Knockout

    Gets or sets the text knockout parameter (PDF 1.4) that determines what PdfTextContent elements shall be considered elementary objects for purposes of color compositing in the transparent imaging model.

    Initial value: true.

    • C#
    • VB.NET
    public bool Knockout { get; set; }
    Public Property Knockout As Boolean
    Property Value
    System.Boolean

    If the value is false, each glyph in a PdfTextContent shall be treated as a separate elementary object; when glyphs overlap, they shall composite with one another. If the value is true, all glyphs in the PdfTextContent shall be treated together as a single elementary object; when glyphs overlap, later glyphs shall overwrite (“knock out”) earlier ones in the area of overlap.

    See Also
    PDF Specification ISO 32000-1:2008, section '9.3.8 Text Knockout'

    Leading

    Gets or sets the leading that specifies the vertical distance between the baselines of adjacent lines of text in unscaled text space units.

    Initial value: 0.

    • C#
    • VB.NET
    public double Leading { get; set; }
    Public Property Leading As Double
    Property Value
    System.Double

    The leading that specifies the vertical distance between the baselines of adjacent lines of text in unscaled text space units.

    Exceptions
    System.ArgumentException

    Value is either System.Double.NaN, System.Double.NegativeInfinity or System.Double.PositiveInfinity.

    See Also
    PDF Specification ISO 32000-1:2008, section '9.3.5 Leading'

    Rise

    Gets or sets the rise that shall specify the distance, in unscaled text space units, to move the baseline up or down from its default location. Positive values of Rise shall move the baseline up.

    Initial value: 0.

    • C#
    • VB.NET
    public double Rise { get; set; }
    Public Property Rise As Double
    Property Value
    System.Double

    The rise that shall specify the distance, in unscaled text space units, to move the baseline up or down from its default location.

    Exceptions
    System.ArgumentException

    Value is either System.Double.NaN, System.Double.NegativeInfinity or System.Double.PositiveInfinity.

    See Also
    PDF Specification ISO 32000-1:2008, section '9.3.7 Text Rise'

    WordSpacing

    Gets or sets the word spacing that works the same way as CharacterSpacing but shall apply only to the ASCII SPACE character (20h).

    Initial value: 0.

    • C#
    • VB.NET
    public double WordSpacing { get; set; }
    Public Property WordSpacing As Double
    Property Value
    System.Double

    The word spacing.

    Exceptions
    System.ArgumentException

    Value is either System.Double.NaN, System.Double.NegativeInfinity or System.Double.PositiveInfinity.

    See Also
    PDF Specification ISO 32000-1:2008, section '9.3.3 Word Spacing'

    Methods

    GetFont(out Double)

    Gets the font and size.

    • C#
    • VB.NET
    public PdfBasicFont GetFont(out double size)
    Public Function GetFont(ByRef size As Double) As PdfBasicFont
    Parameters
    size
    System.Double

    The size.

    Returns
    PdfBasicFont

    The font.

    See Also
    PDF Specification ISO 32000-1:2008, section '9.3 Text State Parameters and Operators'

    SetFont(PdfBasicFont, Double)

    Sets the font and size.

    warning

    Note that the font might not contain all the necessary information to correctly position, render and/or convert to Unicode all characters of the EncodedText so set it at your own risk.

    • C#
    • VB.NET
    public void SetFont(PdfBasicFont font, double size)
    Public Sub SetFont(font As PdfBasicFont, size As Double)
    Parameters
    font
    PdfBasicFont

    The font.

    size
    System.Double

    The size.

    Exceptions
    System.ArgumentNullException

    The font is null.

    System.ArgumentException

    The size is either System.Double.NaN, System.Double.NegativeInfinity or System.Double.PositiveInfinity.

    See Also
    PDF Specification ISO 32000-1:2008, section '9.3 Text State Parameters and Operators'

    Examples

    Reading text info example

    See Also

    PDF Specification ISO 32000-1:2008, section '9.3 Text State Parameters and Operators'
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.