PdfString

Overview

PdfString is a class in Aspose.PDF FOSS for Java. Inherits from: PdfBase.

PDF string object (§7.3.4, ISO 32000-1:2008).

This class provides 20 methods for working with PdfString objects in Java programs. Available methods include: PdfString, accept, equals, fromHex, getAsDate, getBytes, getHexString, getObjectKey, getString, hashCode, isBinary, isDirty, and 7 additional methods. All public members are accessible to any Java application after installing the Aspose.PDF FOSS for Java package. Properties: asDate, binary, bytes, dirty, forceHex, hexString, and 3 more.

Properties

NameTypeAccessDescription
bytesbyte[]ReadReturns the raw bytes of this string.
stringStringReadDecodes the bytes as text: if BOM present, UTF-16BE; otherwise PDFDocEncoding.
forceHexbooleanReadReturns whether this string forces hex serialization.
asDateLocalDateTimeReadAttempts to parse the string as a PDF date.
hexStringStringReadReturns the string in hex representation: <AABBCC…>
Used for binary strings (IDs, encryption keys).
binarybooleanReadReturns true if this string contains non-printable bytes
(likely binary data like file ID or encryption key).
dirtybooleanReadReturns {@code true} if this object was modified since loading.
indirectbooleanReadReturns whether this object is an indirect object (has an object key).
objectKeyPdfObjectKeyReadReturns the indirect object key, or {@code null} for direct objects.

Methods

SignatureDescription
PdfString(bytes: byte[])Creates a PdfString from raw bytes.
PdfString(text: String)Creates a PdfString from a Java string.
fromHex(hex: String)PdfStringCreates a PdfString from a hex string (without angle brackets).
getBytes()byte[]Returns the raw bytes of this string.
getString()StringDecodes the bytes as text: if BOM present, UTF-16BE; otherwise PDFDocEncoding.
setForceHex(forceHex: boolean)Sets whether this string should always be serialized in hex form.
isForceHex()booleanReturns whether this string forces hex serialization.
getAsDate()LocalDateTimeAttempts to parse the string as a PDF date.
getHexString()StringReturns the string in hex representation: <AABBCC…>
Used for binary strings (IDs, encryption keys).
isBinary()booleanReturns true if this string contains non-printable bytes
(likely binary data like file ID or encryption key).
writeTo(os: OutputStream)
accept(visitor: IPdfVisitor<T>)T
equals(o: Object)boolean
hashCode()int
toString()String
isDirty()booleanReturns {@code true} if this object was modified since loading.
setDirty(dirty: boolean)Sets the dirty flag on this object.
isIndirect()booleanReturns whether this object is an indirect object (has an object key).
getObjectKey()PdfObjectKeyReturns the indirect object key, or {@code null} for direct objects.
setObjectKey(key: PdfObjectKey)Sets the indirect object key.

See Also