Class PdfString
PdfString-class is the PDF-equivalent of a JAVA-String-object.
A string is a sequence of characters delimited by parenthesis. If a string is too long to be conveniently placed on a single line, it may be split across multiple lines by using the backslash character (\) at the end of a line to indicate that the string continues on the following line. Within a string, the backslash character is used as an escape to specify unbalanced parenthesis, non-printing ASCII characters, and the backslash character itself. Use of the \ddd escape sequence is the preferred way to represent characters outside the printable ASCII character set.
This object is described in the 'Portable Document Format Reference Manual version 1.7' section 3.2.3 (page 53-56).
- See Also:
-
Field Summary
FieldsFields inherited from class com.itextpdf.kernel.pdf.PdfPrimitiveObject
content, directOnlyFields inherited from class com.itextpdf.kernel.pdf.PdfObject
ARRAY, BOOLEAN, DICTIONARY, FLUSHED, FORBID_RELEASE, FREE, INDIRECT_REFERENCE, indirectReference, LITERAL, MODIFIED, MUST_BE_FLUSHED, MUST_BE_INDIRECT, NAME, NULL, NUMBER, ORIGINAL_OBJECT_STREAM, READ_ONLY, READING, STREAM, STRING, UNENCRYPTED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcopyContent(PdfObject from, PdfDocument document, ICopyFilter copyFilter) Copies object content from object 'from'.protected byte[]protected byte[]encodeBytes(byte[] bytes) Escape special symbols or convert to hexadecimal string.protected booleanencrypt(PdfEncryption encrypt) Encrypt content ofvalueand set as content.booleanprotected voidprotected voidGets the encoding of this string.bytegetType()Gets object type.getValue()byte[]Gets bytes of String-value considering encoding.inthashCode()booleanvoidMarks this string object as not encrypted in the encrypted document.protected PdfObjectCreates new instance of object.setHexWriting(boolean hexWriting) toString()Returns the UnicodeStringvalue of thisPdfString-object.Methods inherited from class com.itextpdf.kernel.pdf.PdfPrimitiveObject
compareContent, getInternalContent, hasContent, makeIndirect, setIndirectReferenceMethods inherited from class com.itextpdf.kernel.pdf.PdfObject
checkState, clearState, clone, clone, containsIndirectReference, copyContent, copyTo, copyTo, copyTo, copyTo, flush, flush, getIndirectReference, isArray, isBoolean, isDictionary, isFlushed, isIndirect, isIndirectReference, isLiteral, isModified, isName, isNull, isNumber, isReleaseForbidden, isStream, isString, makeIndirect, release, setModified, setState
-
Field Details
-
value
-
encoding
-
hexWriting
protected boolean hexWriting
-
-
Constructor Details
-
PdfString
-
PdfString
-
PdfString
public PdfString(byte[] content) -
PdfString
protected PdfString(byte[] content, boolean hexWriting) Only PdfReader can use this method!- Parameters:
-
content- byte content thePdfStringwill be created from -
hexWriting- boolean indicating if hex writing will be used
-
-
Method Details
-
getType
public byte getType()Description copied from class:PdfObjectGets object type. -
isHexWriting
public boolean isHexWriting() -
setHexWriting
-
getValue
-
getEncoding
Gets the encoding of this string.- Returns:
-
the name of the encoding specifying the byte representation of current
PdfStringvalue
-
toUnicodeString
Returns the UnicodeStringvalue of thisPdfString-object.- Returns:
-
Unicode string value created by current
PdfStringobject
-
getValueBytes
public byte[] getValueBytes()Gets bytes of String-value considering encoding.- Returns:
- byte array
-
equals
-
toString
-
hashCode
public int hashCode() -
markAsUnencryptedObject
public void markAsUnencryptedObject()Marks this string object as not encrypted in the encrypted document.If it's marked so, it will be considered as already in plaintext and decryption will not be performed for it. In order to have effect, this method shall be called before
getValue()andgetValueBytes()methods.NOTE: this method is only needed in a very specific cases of encrypted documents. E.g. digital signature dictionary /Contents entry shall not be encrypted. Also this method isn't meaningful in non-encrypted documents.
-
generateValue
protected void generateValue() -
generateContent
protected void generateContent()- Specified by:
-
generateContentin classPdfPrimitiveObject
-
encrypt
Encrypt content ofvalueand set as content.generateContent()won't be called.- Parameters:
-
encrypt-PdfEncryptioninstance - Returns:
- true if value was encrypted, otherwise false.
-
decodeContent
protected byte[] decodeContent() -
encodeBytes
protected byte[] encodeBytes(byte[] bytes) Escape special symbols or convert to hexadecimal string. This method don't change eithervalueorcontentot thePdfString.- Parameters:
-
bytes- byte array to manipulate with. - Returns:
- Hexadecimal string or string with escaped symbols in byte array view.
-
newInstance
Description copied from class:PdfObjectCreates new instance of object.- Specified by:
-
newInstancein classPdfObject - Returns:
- new instance of object.
-
copyContent
Description copied from class:PdfObjectCopies object content from object 'from'.- Overrides:
-
copyContentin classPdfPrimitiveObject - Parameters:
-
from- object to copy content from. -
document- document to copy object to. -
copyFilter-ICopyFiltera filter that will apply on dictionaries and array UseNullCopyFilterfor no filtering
-