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

    Show / Hide Table of Contents

    PdfString Class

    Namespace:
    GemBox.Pdf.Objects
    Assembly:
    GemBox.Pdf.dll

    Represents a basic PDF object that consists of a series of zero or more bytes.

    • C#
    • VB.NET
    public abstract class PdfString : PdfBasicValue, IEnumerable<Byte>, IEnumerable
    Public MustInherit Class PdfString
        Inherits PdfBasicValue
        Implements IEnumerable(Of Byte), IEnumerable
    Inheritance:
    System.Object
    PdfBasicObject
    PdfBasicValue
    PdfString
    Implements
    System.Collections.Generic.IEnumerable<System.Byte>
    System.Collections.IEnumerable

    Properties

    Bytes[Int32]

    Gets the System.Byte value at a specified position in the current PdfString instance.

    • C#
    • VB.NET
    public byte this[int index] { get; }
    Public ReadOnly Property Bytes(index As Integer) As Byte
    Parameters
    index
    System.Int32

    A position in the current PdfString instance.

    Property Value
    System.Byte

    The System.Byte value at a specified position in the current PdfString instance.

    Exceptions
    System.IndexOutOfRangeException

    index is greater than or equal to the Length of this PdfString instance or less than zero.

    Form

    Gets the form in which this PdfString instance shall be written.

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

    The form in which this PdfString instance shall be written.

    Length

    Gets the number of bytes in the current PdfString instance.

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

    The number of bytes in the current PdfString instance.

    ObjectType

    Gets the String value.

    • C#
    • VB.NET
    public sealed override PdfBasicObjectType ObjectType { get; }
    Public NotOverridable Overrides ReadOnly Property ObjectType As PdfBasicObjectType
    Property Value
    PdfBasicObjectType

    The String value.

    Overrides
    PdfBasicObject.ObjectType

    Methods

    Create(DateTimeOffset)

    Creates the date PdfString instance from the specified System.DateTimeOffset value.

    • C#
    • VB.NET
    public static PdfString Create(DateTimeOffset value)
    Public Shared Function Create(value As DateTimeOffset) As PdfString
    Parameters
    value
    System.DateTimeOffset

    The date value.

    Returns
    PdfString

    A date PdfString instance created from the specified System.DateTimeOffset value.

    Remarks

    GemBox.Pdf assembly doesn't publicly expose constructors for types assignable from PdfObject (except PdfDocument), PdfContentElement, and PdfBasicObject types. These types are instead instantiated either through static Create or other factory methods.

    Reasons for this is to support either the current or future extensibility of the type without affecting backward compatibility and without using composition to reduce the number of object allocations.

    For example, PdfNumber type is implemented as PdfInteger and internal PdfReal type. When using Create(Double) method, GemBox.Pdf assembly is able to create either PdfReal or PdfInteger, or return a cached instance of PdfInteger available for an implementation-defined interval of integers, thus reducing memory overhead.

    PdfString and PdfName types have several internal implementations that reduce the number of System.Array allocations.

    PdfArray type is currently implemented as a dynamic array. In the future, GemBox.Pdf assembly might provide an internal implementation that is immutable (without a need to use composition) to reduce memory overhead and optimize cloning operation.

    PdfDictionary type is currently implemented as a hash table with a separate chaining collision resolution. In the future, GemBox.Pdf assembly might provide an internal implementation that uses dynamic array (without a need to use composition) if number of entries is small, to reduce memory overhead and, potentially, improve performance.

    All these current and future implementations would not be possible in a backward compatible way (without unnecessary usage of composition) if constructors were publicly exposed.

    See Also
    PDF Specification ISO 32000-1:2008, section '7.9.4 Dates'

    Create(String)

    Creates the literal text PdfString instance from the specified System.String value.

    If all characters from the value can be encoded with PDFDoc encoding, then PDFDoc encoding will be used; otherwise, UTF16BE encoding will be used.

    • C#
    • VB.NET
    public static PdfString Create(string value)
    Public Shared Function Create(value As String) As PdfString
    Parameters
    value
    System.String

    The string value.

    Returns
    PdfString

    A literal text PdfString instance created from the specified System.String value.

    Remarks

    GemBox.Pdf assembly doesn't publicly expose constructors for types assignable from PdfObject (except PdfDocument), PdfContentElement, and PdfBasicObject types. These types are instead instantiated either through static Create or other factory methods.

    Reasons for this is to support either the current or future extensibility of the type without affecting backward compatibility and without using composition to reduce the number of object allocations.

    For example, PdfNumber type is implemented as PdfInteger and internal PdfReal type. When using Create(Double) method, GemBox.Pdf assembly is able to create either PdfReal or PdfInteger, or return a cached instance of PdfInteger available for an implementation-defined interval of integers, thus reducing memory overhead.

    PdfString and PdfName types have several internal implementations that reduce the number of System.Array allocations.

    PdfArray type is currently implemented as a dynamic array. In the future, GemBox.Pdf assembly might provide an internal implementation that is immutable (without a need to use composition) to reduce memory overhead and optimize cloning operation.

    PdfDictionary type is currently implemented as a hash table with a separate chaining collision resolution. In the future, GemBox.Pdf assembly might provide an internal implementation that uses dynamic array (without a need to use composition) if number of entries is small, to reduce memory overhead and, potentially, improve performance.

    All these current and future implementations would not be possible in a backward compatible way (without unnecessary usage of composition) if constructors were publicly exposed.

    Exceptions
    System.ArgumentNullException

    value is null.

    See Also
    PDF Specification ISO 32000-1:2008, section '7.9.2.2 Text String Type'

    Create(String, IPdfEncoding, PdfStringForm)

    Creates the PdfString instance from the specified System.String value.

    • C#
    • VB.NET
    public static PdfString Create(string value, IPdfEncoding encoding, PdfStringForm form)
    Public Shared Function Create(value As String, encoding As IPdfEncoding, form As PdfStringForm) As PdfString
    Parameters
    value
    System.String

    The string value.

    encoding
    IPdfEncoding

    The encoding used to encode the value.

    form
    PdfStringForm

    The form in which created PdfString instance shall be written.

    Returns
    PdfString

    A PdfString instance created from the specified System.String value.

    Remarks

    GemBox.Pdf assembly doesn't publicly expose constructors for types assignable from PdfObject (except PdfDocument), PdfContentElement, and PdfBasicObject types. These types are instead instantiated either through static Create or other factory methods.

    Reasons for this is to support either the current or future extensibility of the type without affecting backward compatibility and without using composition to reduce the number of object allocations.

    For example, PdfNumber type is implemented as PdfInteger and internal PdfReal type. When using Create(Double) method, GemBox.Pdf assembly is able to create either PdfReal or PdfInteger, or return a cached instance of PdfInteger available for an implementation-defined interval of integers, thus reducing memory overhead.

    PdfString and PdfName types have several internal implementations that reduce the number of System.Array allocations.

    PdfArray type is currently implemented as a dynamic array. In the future, GemBox.Pdf assembly might provide an internal implementation that is immutable (without a need to use composition) to reduce memory overhead and optimize cloning operation.

    PdfDictionary type is currently implemented as a hash table with a separate chaining collision resolution. In the future, GemBox.Pdf assembly might provide an internal implementation that uses dynamic array (without a need to use composition) if number of entries is small, to reduce memory overhead and, potentially, improve performance.

    All these current and future implementations would not be possible in a backward compatible way (without unnecessary usage of composition) if constructors were publicly exposed.

    Exceptions
    System.ArgumentNullException

    value is null or encoding is null.

    See Also
    GemBox.Pdf.Objects.IPdfAttachedObject

    Equals(Object)

    Determines whether the specified System.Object is equal to this PdfString instance.

    • C#
    • VB.NET
    public sealed override bool Equals(object obj)
    Public NotOverridable Overrides Function Equals(obj As Object) As Boolean
    Parameters
    obj
    System.Object

    The System.Object to compare with this PdfString instance.

    Returns
    System.Boolean

    true if the specified System.Object is equal to this PdfString instance; otherwise, false.

    Overrides
    PdfBasicValue.Equals(Object)

    GetEnumerator()

    Returns an enumerator that iterates through the PdfString.

    • C#
    • VB.NET
    public PdfString.Enumerator GetEnumerator()
    Public Function GetEnumerator As PdfString.Enumerator
    Returns
    PdfString.Enumerator

    A PdfString.Enumerator for the PdfString.

    GetHashCode()

    Returns a hash code for this PdfString instance.

    • C#
    • VB.NET
    public sealed override int GetHashCode()
    Public NotOverridable Overrides Function GetHashCode As Integer
    Returns
    System.Int32

    A hash code for this PdfString instance, suitable for use in hashing algorithms and data structures like a hash table.

    Overrides
    PdfBasicValue.GetHashCode()

    ToString()

    Returns a System.String that represents this PdfString instance.

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

    A System.String that represents this PdfString instance.

    Overrides
    PdfBasicObject.ToString()
    Remarks

    If the PdfString starts with the 0xFE 0xFF bytes, then UTF16BE encoding will be used; otherwise, if all bytes from this PdfString can be decoded with PDFDoc encoding, then PDFDoc encoding will be used; otherwise, Byte encoding is used.

    ToString(IPdfEncoding)

    Returns a System.String that represents this PdfString instance in the specified encoding.

    • C#
    • VB.NET
    public string ToString(IPdfEncoding encoding)
    Public Function ToString(encoding As IPdfEncoding) As String
    Parameters
    encoding
    IPdfEncoding

    The encoding used to decode this PdfString instance to System.String.

    Returns
    System.String

    A System.String that represents this PdfString instance in the specified encoding.

    Exceptions
    System.ArgumentNullException

    encoding is null.

    Inherited Properties

    Null

    Gets the single instance of Null type.

    (Inherited from PdfBasicObject)

    Implements

    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable

    Examples

    Basic Objects example

    See Also

    PDF Specification ISO 32000-1:2008, section '7.3.4 String Objects'
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.