public class PDFText extends PDFObject
Constructor and Description |
---|
PDFText() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
escapeByteArray(byte[] data)
Escape a byte array for output to PDF (Used for encrypted strings)
|
static String |
escapeString(String s)
Escaped a String as described in section 4.4 in the PDF 1.3 specs.
|
static void |
escapeStringChar(char c,
StringBuffer target)
Escapes a character conforming to the rules established in the PostScript
Language Reference (Search for "Literal Text Strings").
|
static String |
escapeText(String text)
Escape text (see 4.4.1 in PDF 1.3 specs)
|
static String |
escapeText(String text,
boolean forceHexMode)
Escape text (see 4.4.1 in PDF 1.3 specs)
|
String |
getText()
Returns the text.
|
void |
setText(String text)
Sets the text.
|
static String |
toHex(byte[] data)
Converts a byte array to a Hexadecimal String (3.2.3 in PDF 1.4 specs)
|
static String |
toHex(byte[] data,
boolean brackets)
Converts a byte array to a Hexadecimal String (3.2.3 in PDF 1.4 specs)
|
protected String |
toPDFString()
This method returns a String representation of the PDF object.
|
static String |
toPDFString(CharSequence text)
Converts a text to PDF's "string" data type.
|
static String |
toPDFString(CharSequence text,
char replacement)
Converts a text to PDF's "string" data type.
|
static String |
toUnicodeHex(char c)
Convert a char to a multibyte hex representation
|
static void |
toUnicodeHex(int c,
StringBuffer sb)
Convert a char to a multibyte hex representation appending to string buffer.
|
static byte[] |
toUTF16(String text)
Converts a String to UTF-16 (big endian).
|
contentEquals, encode, encodeBinaryToHexString, encodeString, encodeText, formatObject, getChildren, getDocument, getDocumentSafely, getGeneration, getObjectID, getObjectNumber, getParent, hasObjectNumber, makeReference, output, outputInline, referencePDF, setDocument, setObjectNumber, setObjectNumber, setObjectNumber, setParent, supportsObjectStream, toPDF
public String getText()
public void setText(String text)
text
- the textprotected String toPDFString()
toPDFString
in class PDFObject
public static final String escapeText(String text)
text
- the text to encodepublic static final String escapeText(String text, boolean forceHexMode)
text
- the text to encodeforceHexMode
- true if the output should follow the hex encoding rulespublic static final String toHex(byte[] data, boolean brackets)
data
- the data to encodebrackets
- true if enclosing brackets should be includedpublic static final String toHex(byte[] data)
data
- the data to encodepublic static final byte[] toUTF16(String text)
text
- text to convertpublic static final String toUnicodeHex(char c)
c
- character to encodepublic static final void toUnicodeHex(int c, StringBuffer sb)
c
- character to encodesb
- the string buffer to append outputpublic static final String escapeString(String s)
s
- String to escapepublic static final void escapeStringChar(char c, StringBuffer target)
c
- character to escapetarget
- target StringBuffer to write the escaped character topublic static final byte[] escapeByteArray(byte[] data)
data
- data to encodepublic static String toPDFString(CharSequence text)
text
- the text to converttoPDFString(CharSequence, char)
public static String toPDFString(CharSequence text, char replacement)
The PDF library currently doesn't properly distinguish between the PDF data types "string" and "text string", so we currently restrict "string" to US-ASCII, also because "string" seems somewhat under-specified concerning the upper 128 bytes.
text
- the text to convertreplacement
- the replacement character used when substituting a characterCopyright © 2025 Apache Software Foundation. All rights reserved.