Package com.lowagie.text.pdf
Class PdfEncodings
java.lang.Object
com.lowagie.text.pdf.PdfEncodings
Supports fast encodings for winansi and PDFDocEncoding. Supports conversions from CJK encodings to CID. Supports
custom encodings.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
private static class
private static class
private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
protected static final int
protected static final int
(package private) static final ConcurrentHashMap
<String, char[][]> static final byte[][]
Assumes that '\\n' and '\\r\\n' are the newline sequences.(package private) static ConcurrentHashMap
<String, ExtraEncoding> (package private) static final IntHashtable
(package private) static final char[]
(package private) static final IntHashtable
(package private) static final char[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addExtraEncoding
(String name, ExtraEncoding enc) Adds an extra encoding.(package private) static void
breakLong
(long n, int size, byte[] seqs) static void
Clears the CJK cmaps from the cache.static String
convertCmap
(String name, byte[] seq) Converts abyte
array encoded asname
to a CID string.static String
convertCmap
(String name, byte[] seq, int start, int length) Converts abyte
array encoded asname
to a CID string.static final byte[]
convertToBytes
(char char1, String encoding) Converts aString
to abyte
array according to the font's encoding.static final byte[]
convertToBytes
(String text, String encoding) Converts aString
to abyte
array according to the font's encoding.static final String
convertToString
(byte[] bytes, String encoding) Converts abyte
array to aString
according to the some encoding.(package private) static String
decodeSequence
(byte[] seq, int start, int length, char[][] planes) (package private) static void
encodeSequence
(int size, byte[] seqs, char cid, ArrayList<char[]> planes) (package private) static void
encodeStream
(InputStream in, ArrayList<char[]> planes) static boolean
isPdfDocEncoding
(String text) Checks istext
only has PdfDocEncoding characters.static void
Loads a CJK cmap to the cache with the option of associating sequences to the newline.(package private) static char[][]
(package private) static void
-
Field Details
-
CRLF_CID_NEWLINE
public static final byte[][] CRLF_CID_NEWLINEAssumes that '\\n' and '\\r\\n' are the newline sequences. It may not work for all CJK encodings. To be used with loadCmap(). -
CIDNONE
protected static final int CIDNONE- See Also:
-
CIDRANGE
protected static final int CIDRANGE- See Also:
-
CIDCHAR
protected static final int CIDCHAR- See Also:
-
winansiByteToChar
static final char[] winansiByteToChar -
pdfEncodingByteToChar
static final char[] pdfEncodingByteToChar -
winansi
-
pdfEncoding
-
cmaps
-
extraEncodings
-
-
Constructor Details
-
PdfEncodings
public PdfEncodings()
-
-
Method Details
-
convertToBytes
Converts aString
to abyte
array according to the font's encoding.- Parameters:
text
- theString
to be convertedencoding
- the encoding- Returns:
- an array of
byte
representing the conversion according to the font's encoding
-
convertToBytes
Converts aString
to abyte
array according to the font's encoding.- Parameters:
char1
- thechar
to be convertedencoding
- the encoding- Returns:
- an array of
byte
representing the conversion according to the font's encoding
-
convertToString
Converts abyte
array to aString
according to the some encoding.- Parameters:
bytes
- the bytes to convertencoding
- the encoding- Returns:
- the converted
String
-
isPdfDocEncoding
Checks istext
only has PdfDocEncoding characters.- Parameters:
text
- theString
to test- Returns:
true
if only PdfDocEncoding characters are present
-
clearCmap
Clears the CJK cmaps from the cache. Ifname
is the empty string then all the cache is cleared. Calling this method has no consequences other than the need to reload the cmap if needed.- Parameters:
name
- the name of the cmap to clear or all the cmaps if the empty string
-
loadCmap
Loads a CJK cmap to the cache with the option of associating sequences to the newline.- Parameters:
name
- the CJK cmap namenewline
- the sequences to be replaced by a newline in the resulting CID. SeeCRLF_CID_NEWLINE
-
convertCmap
Converts abyte
array encoded asname
to a CID string. This is needed to reach some CJK characters that don't exist in 16 bit Unicode.The font to use this result must use the encoding "Identity-H" or "Identity-V".
See ftp://ftp.oreilly.com/pub/examples/nutshell/cjkv/adobe/.- Parameters:
name
- the CJK encoding nameseq
- thebyte
array to be decoded- Returns:
- the CID string
-
convertCmap
Converts abyte
array encoded asname
to a CID string. This is needed to reach some CJK characters that don't exist in 16 bit Unicode.The font to use this result must use the encoding "Identity-H" or "Identity-V".
See ftp://ftp.oreilly.com/pub/examples/nutshell/cjkv/adobe/.- Parameters:
name
- the CJK encoding nameseq
- thebyte
array to be decodedstart
- the start offset in the datalength
- the number of bytes to convert- Returns:
- the CID string
-
decodeSequence
-
readCmap
- Throws:
IOException
-
readCmap
- Throws:
IOException
-
encodeStream
- Throws:
IOException
-
breakLong
static void breakLong(long n, int size, byte[] seqs) -
encodeSequence
-
addExtraEncoding
Adds an extra encoding.- Parameters:
name
- the name of the encoding. The encoding recognition is case insensitiveenc
- the conversion class
-