Package com.itextpdf.text.pdf
Class PdfString
- java.lang.Object
-
- com.itextpdf.text.pdf.PdfObject
-
- com.itextpdf.text.pdf.PdfString
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
PdfDate
public class PdfString extends PdfObject
APdfString
-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:
PdfObject
,BadPdfFormatException
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
encoding
The encoding.protected boolean
hexWriting
protected int
objGen
protected int
objNum
protected java.lang.String
originalValue
protected java.lang.String
value
The value of this object.
-
Constructor Summary
Constructors Constructor Description PdfString()
Constructs an emptyPdfString
-object.PdfString(byte[] bytes)
Constructs aPdfString
-object.PdfString(java.lang.String value)
Constructs aPdfString
-object containing a string in the standard encodingTEXT_PDFDOCENCODING
.PdfString(java.lang.String value, java.lang.String encoding)
Constructs aPdfString
-object containing a string in the specified encoding.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
decrypt(PdfReader reader)
Decrypt an encryptedPdfString
byte[]
getBytes()
Gets the presentation of this object in a byte arrayjava.lang.String
getEncoding()
Gets the encoding of this string.byte[]
getOriginalBytes()
boolean
isHexWriting()
PdfString
setHexWriting(boolean hexWriting)
(package private) void
setObjNum(int objNum, int objGen)
void
toPdf(PdfWriter writer, java.io.OutputStream os)
Writes the PDF representation of thisPdfString
as an array ofbyte
to the specifiedOutputStream
.java.lang.String
toString()
Returns theString
value of thisPdfString
-object.java.lang.String
toUnicodeString()
Returns the UnicodeString
value of thisPdfString
-object.-
Methods inherited from class com.itextpdf.text.pdf.PdfObject
canBeInObjStm, getIndRef, isArray, isBoolean, isDictionary, isIndirect, isName, isNull, isNumber, isStream, isString, length, setContent, setIndRef, type
-
-
-
-
Constructor Detail
-
PdfString
public PdfString()
Constructs an emptyPdfString
-object.
-
PdfString
public PdfString(java.lang.String value)
Constructs aPdfString
-object containing a string in the standard encodingTEXT_PDFDOCENCODING
.- Parameters:
value
- the content of the string
-
PdfString
public PdfString(java.lang.String value, java.lang.String encoding)
Constructs aPdfString
-object containing a string in the specified encoding.- Parameters:
value
- the content of the stringencoding
- an encoding
-
PdfString
public PdfString(byte[] bytes)
Constructs aPdfString
-object.- Parameters:
bytes
- an array ofbyte
-
-
Method Detail
-
toPdf
public void toPdf(PdfWriter writer, java.io.OutputStream os) throws java.io.IOException
Writes the PDF representation of thisPdfString
as an array ofbyte
to the specifiedOutputStream
.
-
toString
public java.lang.String toString()
Returns theString
value of thisPdfString
-object.
-
getBytes
public byte[] getBytes()
Description copied from class:PdfObject
Gets the presentation of this object in a byte array
-
toUnicodeString
public java.lang.String toUnicodeString()
Returns the UnicodeString
value of thisPdfString
-object.- Returns:
- A
String
-
getEncoding
public java.lang.String getEncoding()
Gets the encoding of this string.- Returns:
- a
String
-
setObjNum
void setObjNum(int objNum, int objGen)
-
decrypt
void decrypt(PdfReader reader)
Decrypt an encryptedPdfString
-
getOriginalBytes
public byte[] getOriginalBytes()
-
setHexWriting
public PdfString setHexWriting(boolean hexWriting)
-
isHexWriting
public boolean isHexWriting()
-
-