PdfString Class
Represents a basic PDF object that consists of a series of zero or more bytes.
public abstract class PdfString : PdfBasicValue, IEnumerable<Byte>, IEnumerable
Public MustInherit Class PdfString
Inherits PdfBasicValue
Implements IEnumerable(Of Byte), IEnumerable
- Inheritance:
- System.ObjectPdfString
Implements
Properties
Bytes[Int32]
Gets the System.Byte value at a specified position in the current PdfString instance.
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
Form
Gets the form in which this PdfString instance shall be written.
Property Value
The form in which this PdfString instance shall be written.
Length
Gets the number of bytes in the current PdfString instance.
Property Value
- System.Int32
The number of bytes in the current PdfString instance.
ObjectType
Gets the String value.
public sealed override PdfBasicObjectType ObjectType { get; }
Public NotOverridable Overrides ReadOnly Property ObjectType As PdfBasicObjectType
Property Value
The String value.
Overrides
Methods
Create(DateTimeOffset)
Creates the date PdfString instance from the specified System.DateTimeOffset value.
public static PdfString Create(DateTimeOffset value)
Public Shared Function Create(value As DateTimeOffset) As PdfString
Parameters
value
- System.DateTimeOffset
The date value.
Returns
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
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.
public static PdfString Create(string value)
Public Shared Function Create(value As String) As PdfString
Parameters
value
- System.String
The string value.
Returns
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
Create(String, IPdfEncoding, PdfStringForm)
Creates the PdfString instance from the specified System.String value.
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
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
Equals(Object)
Determines whether the specified System.Object is equal to this PdfString instance.
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
GetEnumerator()
Returns an enumerator that iterates through the PdfString.
public PdfString.Enumerator GetEnumerator()
Public Function GetEnumerator As PdfString.Enumerator
Returns
GetHashCode()
Returns a hash code for this PdfString instance.
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
ToString()
Returns a System.String that represents this PdfString instance.
public sealed override string ToString()
Public NotOverridable Overrides Function ToString As String
Returns
- System.String
A System.String that represents this PdfString instance.
Overrides
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.
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) |