org.apache.fop.pdf

Class PDFText

Implemented Interfaces:
PDFWritable

public class PDFText
extends PDFObject

This class represents a simple number object. It also contains contains some utility methods for outputing numbers to PDF.

Field Summary

Fields inherited from class org.apache.fop.pdf.PDFObject

DATE_FORMAT, log

Method Summary

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)
protected String
toPDFString()
static byte[]
toUTF16(String text)
Converts a String to UTF-16 (big endian).
static String
toUnicodeHex(char c)
Convert a char to a multibyte hex representation

Methods inherited from class org.apache.fop.pdf.PDFObject

encode, encodeString, encodeText, formatDateTime, formatObject, getDocument, getDocumentSafely, getGeneration, getObjectID, getObjectNumber, hasObjectNumber, makeReference, output, referencePDF, setDocument, setObjectNumber, toInlinePDFString, toPDF, toPDFString

Method Details

escapeByteArray

public static final byte[] escapeByteArray(byte[] data)
Escape a byte array for output to PDF (Used for encrypted strings)
Parameters:
data - data to encode
Returns:
byte[] encoded data

escapeString

public static final String escapeString(String s)
Escaped a String as described in section 4.4 in the PDF 1.3 specs.
Parameters:
s - String to escape
Returns:
String the escaped String

escapeStringChar

public static final void escapeStringChar(char c,
                                          StringBuffer target)
Escapes a character conforming to the rules established in the PostScript Language Reference (Search for "Literal Text Strings").
Parameters:
c - character to escape
target - target StringBuffer to write the escaped character to

escapeText

public static final String escapeText(String text)
Escape text (see 4.4.1 in PDF 1.3 specs)
Parameters:
text - the text to encode
Returns:
encoded text

escapeText

public static final String escapeText(String text,
                                      boolean forceHexMode)
Escape text (see 4.4.1 in PDF 1.3 specs)
Parameters:
text - the text to encode
forceHexMode - true if the output should follow the hex encoding rules
Returns:
encoded text

getText

public String getText()
Returns the text.
Returns:
the text

setText

public void setText(String text)
Sets the text.
Parameters:
text - the text

toHex

public static final String toHex(byte[] data)
Converts a byte array to a Hexadecimal String (3.2.3 in PDF 1.4 specs)
Parameters:
data - the data to encode
Returns:
String the resulting string

toPDFString

protected String toPDFString()
Overrides:
toPDFString in interface PDFObject

toUTF16

public static final byte[] toUTF16(String text)
Converts a String to UTF-16 (big endian).
Parameters:
text - text to convert
Returns:
byte[] UTF-16 stream

toUnicodeHex

public static final String toUnicodeHex(char c)
Convert a char to a multibyte hex representation
Parameters:
c - character to encode
Returns:
the encoded character

Copyright 1999-2007 The Apache Software Foundation. All Rights Reserved.