PdfString Class
A string: a sequence of bytes (ISO 32000-2, 7.3.4). It is immutable.
public sealed class PdfString : PdfObject, IEquatable<PdfString>Remarks
A text string (7.9.2.2) is encoded with PDFDocEncoding, UTF-16BE or UTF-8, the last two with a byte order mark: PdfString.FromText and PdfString.ToText convert it.
- Inheritance
PdfObjectPdfString- Implements
Properties
| Name | Description |
|---|---|
| Bytes | Gets the bytes of the string. |
| IsHexadecimal | Gets a value indicating whether the string is written in hexadecimal form (<48656C6C6F>) rather than as a literal ((Hello)). |
| Kind | Gets the kind of the object. |
Bytes
PdfString.csIsHexadecimal
PdfString.csKind
PdfString.csMethods
| Name | Description |
|---|---|
| Equals(PdfString?) | Indicates whether the current object is equal to another object of the same type. |
| Equals(object?) | Determines whether the specified object is equal to the current object. |
| FromBytes(ReadOnlySpan<byte>, bool) | Creates a string from bytes. |
| FromText(string) | Creates a text string (ISO 32000-2, 7.9.2.2): PDFDocEncoding when every character has a code in it, otherwise UTF-16BE with a byte order mark. |
| GetHashCode() | Serves as the default hash function. |
| ToText() | Decodes the string as a text string (ISO 32000-2, 7.9.2.2): UTF-16BE or UTF-8 when it starts with their byte order mark, otherwise PDFDocEncoding. |
Equals overloads
Equals(PdfString?)
PdfString.csIndicates whether the current object is equal to another object of the same type.
Parameters
otherPdfString?- An object to compare with this object.
Returns
bool true if the current object is equal to the other parameter; otherwise, false.
Equals(object?)
PdfString.csFromBytes(ReadOnlySpan<byte>, bool)
PdfString.csCreates a string from bytes.
public static PdfString FromBytes(ReadOnlySpan<byte> bytes, bool hexadecimal = false)Parameters
bytesReadOnlySpan<byte>- The bytes.
hexadecimalbool- Whether the string is written in hexadecimal form.
Returns
PdfString The string.