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, directOnlyARRAY, 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| 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 PdfString |
decrypt(PdfEncryption decrypt)
Decrypt content of an encrypted
PdfString. |
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. |
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.
|
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.
|
protected PdfString |
newInstance()
Creates new instance of object.
|
void |
setEncoding(String encoding)
Sets the encoding of this string.
|
PdfString |
setHexWriting(boolean hexWriting) |
String |
toString() |
String |
toUnicodeString()
Returns the Unicode
String value of this
PdfString-object. |
compareContent, getInternalContent, hasContent, setIndirectReferencecheckState, clearState, clone, flush, flush, getIndirectReference, isArray, isBoolean, isDictionary, isFlushed, isIndirect, isIndirectReference, isLiteral, isModified, isName, isNull, isNumber, isStream, isString, release, setModified, setStateprotected 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()
PdfObjectpublic boolean isHexWriting()
public PdfString setHexWriting(boolean hexWriting)
public String getValue()
public String getEncoding()
public void setEncoding(String encoding)
public String toUnicodeString()
String value of this
PdfString-object.public byte[] getValueBytes()
public PdfString makeIndirect(PdfDocument document)
makeIndirect in class PdfObjectdocument - a document the indirect reference will belong to.public PdfString makeIndirect(PdfDocument document, PdfIndirectReference reference)
makeIndirect in class PdfPrimitiveObjectdocument - a document the indirect reference will belong to.public PdfString copyTo(PdfDocument document)
public PdfString copyTo(PdfDocument document, boolean allowDuplicating)
copyTo in class PdfObjectdocument - 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.protected void generateValue()
protected void generateContent()
generateContent in class PdfPrimitiveObjectprotected PdfString decrypt(PdfEncryption decrypt)
PdfString.protected boolean encrypt(PdfEncryption encrypt)
value and set as content. generateContent() won't be called.encrypt - @see PdfEncryptionprotected byte[] encodeBytes(byte[] bytes)
value or content ot the PdfString.bytes - byte array to manipulate with.protected PdfString newInstance()
PdfObjectnewInstance in class PdfObjectprotected void copyContent(PdfObject from, PdfDocument document)
PdfObjectcopyContent in class PdfPrimitiveObjectfrom - object to copy content from.document - document to copy object to.Copyright © 1998–2016 iText Group NV. All rights reserved.