public class PdfString extends PdfObject
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,
BadPdfFormatException| Modifier and Type | Field and Description |
|---|---|
protected String |
encoding
The encoding.
|
protected boolean |
hexWriting |
protected int |
objGen |
protected int |
objNum |
protected String |
originalValue |
protected String |
value
The value of this object.
|
| Constructor and Description |
|---|
PdfString()
Constructs an empty
PdfString-object. |
PdfString(byte[] bytes)
Constructs a
PdfString-object. |
PdfString(String value)
Constructs a
PdfString-object containing a string in the standard encoding
TEXT_PDFDOCENCODING. |
PdfString(String value,
String encoding)
Constructs a
PdfString-object containing a string in the specified encoding. |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
getBytes()
Gets the presentation of this object in a byte array
|
String |
getEncoding()
Gets the encoding of this string.
|
byte[] |
getOriginalBytes() |
char[] |
getOriginalChars()
return the characters in our value without any translation.
|
boolean |
isHexWriting() |
PdfString |
setHexWriting(boolean hexWriting) |
void |
toPdf(PdfWriter writer,
OutputStream os)
Writes the PDF representation of this
PdfString as an array of byte to the specified
OutputStream. |
String |
toString()
Returns the
String value of this PdfString-object. |
String |
toUnicodeString()
Returns the Unicode
String value of this
PdfString-object. |
canBeInObjStm, getIndRef, isArray, isBoolean, isDictionary, isIndirect, isName, isNull, isNumber, isStream, isString, length, setContent, setIndRef, typeprotected String value
protected String originalValue
protected String encoding
protected int objNum
protected int objGen
protected boolean hexWriting
public PdfString()
PdfString-object.public PdfString(String value)
PdfString-object containing a string in the standard encoding
TEXT_PDFDOCENCODING.value - the content of the stringpublic PdfString(String value, String encoding)
PdfString-object containing a string in the specified encoding.value - the content of the stringencoding - an encodingpublic PdfString(byte[] bytes)
PdfString-object.bytes - an array of bytepublic void toPdf(PdfWriter writer, OutputStream os) throws IOException
PdfString as an array of byte to the specified
OutputStream.toPdf in class PdfObjectwriter - for backwards compatibilityos - The OutputStream to write the bytes to.IOException - on errorpublic String toString()
String value of this PdfString-object.public byte[] getBytes()
PdfObjectpublic String toUnicodeString()
String value of this
PdfString-object.Stringpublic String getEncoding()
Stringpublic byte[] getOriginalBytes()
public char[] getOriginalChars()
Intended for use when no encoding transformations are desired.
public boolean isHexWriting()
public PdfString setHexWriting(boolean hexWriting)
Copyright © 2024. All rights reserved.