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.
PdfObject
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'.
|
PdfString |
copyTo(PdfDocument document)
Copies object to a specified document.
|
PdfString |
copyTo(PdfDocument document, boolean allowDuplicating)
Copies object to a specified document.
|
protected byte[] |
decodeContent() |
protected PdfString |
decrypt(PdfEncryption decrypt)
Deprecated.
use
decodeContent() or getValue() methods, they will decrypt bytes if they are encrypted. Will be removed in iText 7.1
|
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() |
PdfString |
makeIndirect(PdfDocument document)
Marks object to be saved as indirect.
|
PdfString |
makeIndirect(PdfDocument document, PdfIndirectReference reference)
Marks object to be saved as indirect.
|
void |
markAsUnencryptedObject()
Marks this string object as not encrypted in the encrypted document.
|
protected PdfString |
newInstance()
Creates new instance of object.
|
void |
setEncoding(String encoding)
Deprecated.
Create a new instance with
PdfString(String, String) instead.
|
PdfString |
setHexWriting(boolean hexWriting) |
String |
toString() |
String |
toUnicodeString()
Returns the Unicode String value of this PdfString -object.
|
compareContent, getInternalContent, hasContent, setIndirectReference
checkState, clearState, clone, flush, flush, getIndirectReference, isArray, isBoolean, isDictionary, isFlushed, isIndirect, isIndirectReference, isLiteral, isModified, isName, isNull, isNumber, isStream, isString, 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)
public byte getType()
PdfObject
public boolean isHexWriting()
public PdfString setHexWriting(boolean hexWriting)
public String getValue()
public String getEncoding()
@Deprecated public void setEncoding(String encoding)
PdfString(String, String)
instead.
public String toUnicodeString()
String
value of this PdfString
-object.
public byte[] getValueBytes()
public PdfString makeIndirect(PdfDocument document)
makeIndirect
in class PdfObject
document
- a document the indirect reference will belong to.
public PdfString makeIndirect(PdfDocument document, PdfIndirectReference reference)
makeIndirect
in class PdfPrimitiveObject
document
- a document the indirect reference will belong to.
public PdfString copyTo(PdfDocument document)
public PdfString copyTo(PdfDocument document, boolean allowDuplicating)
copyTo
in class PdfObject
document
- document to copy object to.
allowDuplicating
- indicates if to allow copy objects which already have been copied. If object is associated with any indirect reference and allowDuplicating is false then already existing reference will be returned instead of copying object. If allowDuplicating is true then object will be copied and new indirect reference will be assigned.
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
@Deprecated protected PdfString decrypt(PdfEncryption decrypt)
decodeContent()
or getValue()
methods, they will decrypt bytes if they are encrypted. Will be removed in iText 7.1
PdfString
.
protected boolean encrypt(PdfEncryption encrypt)
value
and set as content. generateContent()
won't be called.
encrypt
- @see PdfEncryption
protected byte[] decodeContent()
protected byte[] encodeBytes(byte[] bytes)
value
or content
ot the PdfString
.
bytes
- byte array to manipulate with.
protected PdfString 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–2017 iText Group NV. All rights reserved.