public class PdfString extends PdfPrimitiveObject
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).
PdfObject
, Serialized Form
Modifier and Type | Field and Description |
---|---|
protected String |
encoding |
protected boolean |
hexWriting |
protected String |
value |
content, directOnly
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
Modifier | Constructor and Description |
---|---|
|
PdfString(byte[] content) |
protected |
PdfString(byte[] content, boolean hexWriting)
Only PdfReader can use this method!
|
|
PdfString(String value) |
|
PdfString(String value, String encoding) |
Modifier and Type | Method and Description |
---|---|
protected void |
copyContent(PdfObject from, PdfDocument document)
Copies object content from object 'from'.
|
protected byte[] |
decodeContent() |
protected byte[] |
encodeBytes(byte[] bytes)
Escape special symbols or convert to hexadecimal string.
|
protected boolean |
encrypt(PdfEncryption encrypt)
Encrypt content of value and set as content.
|
boolean |
equals(Object o) |
protected void |
generateContent() |
protected void |
generateValue() |
String |
getEncoding()
Gets the encoding of this string.
|
byte |
getType()
Gets object type.
|
String |
getValue() |
byte[] |
getValueBytes()
Gets bytes of String-value considering encoding.
|
int |
hashCode() |
boolean |
isHexWriting() |
void |
markAsUnencryptedObject()
Marks this string object as not encrypted in the encrypted document.
|
protected PdfObject |
newInstance()
Creates new instance of object.
|
PdfString |
setHexWriting(boolean hexWriting) |
String |
toString() |
String |
toUnicodeString()
Returns the Unicode String value of this PdfString -object.
|
compareContent, getInternalContent, hasContent, makeIndirect, setIndirectReference
checkState, clearState, clone, copyTo, copyTo, flush, flush, getIndirectReference, isArray, isBoolean, isDictionary, isFlushed, isIndirect, isIndirectReference, isLiteral, isModified, isName, isNull, isNumber, isReleaseForbidden, isStream, isString, makeIndirect, release, setModified, setState
protected String value
protected String encoding
protected boolean hexWriting
public PdfString(String value)
public PdfString(byte[] content)
protected PdfString(byte[] content, boolean hexWriting)
content
- byte content the PdfString
will be created from
hexWriting
- boolean indicating if hex writing will be used
public byte getType()
PdfObject
public boolean isHexWriting()
public PdfString setHexWriting(boolean hexWriting)
public String getValue()
public String getEncoding()
PdfString
value
public String toUnicodeString()
String
value of this PdfString
-object.
PdfString
object
public byte[] getValueBytes()
public void markAsUnencryptedObject()
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()
and getValueBytes()
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.
protected void generateValue()
protected void generateContent()
generateContent
in class PdfPrimitiveObject
protected boolean encrypt(PdfEncryption encrypt)
value
and set as content. generateContent()
won't be called.
encrypt
- PdfEncryption
instance
protected byte[] decodeContent()
protected byte[] encodeBytes(byte[] bytes)
value
or content
ot the PdfString
.
bytes
- byte array to manipulate with.
protected PdfObject newInstance()
PdfObject
newInstance
in class PdfObject
protected void copyContent(PdfObject from, PdfDocument document)
PdfObject
copyContent
in class PdfPrimitiveObject
from
- object to copy content from.
document
- document to copy object to.
Copyright © 1998–2023 iText Group NV. All rights reserved.