public class PdfEncodings extends Object
Modifier and Type | Field and Description |
---|---|
protected static int |
CIDCHAR |
protected static int |
CIDNONE |
protected static int |
CIDRANGE |
static byte[][] |
CRLF_CID_NEWLINE
Assumes that '\\n' and '\\r\\n' are the newline sequences.
|
Constructor and Description |
---|
PdfEncodings() |
Modifier and Type | Method and Description |
---|---|
static void |
addExtraEncoding(String name,
ExtraEncoding enc)
Adds an extra encoding.
|
static void |
clearCmap(String name)
Clears the CJK cmaps from the cache.
|
static String |
convertCmap(String name,
byte[] seq)
Converts a
byte array encoded as name to a CID
string. |
static String |
convertCmap(String name,
byte[] seq,
int start,
int length)
Converts a
byte array encoded as name to a CID
string. |
static byte[] |
convertToBytes(char char1,
String encoding)
Converts a
String to a byte array according to
the font's encoding. |
static byte[] |
convertToBytes(String text,
String encoding)
Converts a
String to a byte array according to
the font's encoding. |
static String |
convertToString(byte[] bytes,
String encoding)
Converts a byte array to a
String according to
the some encoding. |
static boolean |
isPdfDocEncoding(String text)
Checks is
text only has PdfDocEncoding characters. |
static void |
loadCmap(String name,
byte[][] newline)
Loads a CJK cmap to the cache with the option of associating sequences to
the newline.
|
protected static final int CIDNONE
protected static final int CIDRANGE
protected static final int CIDCHAR
public static final byte[][] CRLF_CID_NEWLINE
public static final byte[] convertToBytes(String text, String encoding)
String
to a byte array according to
the font's encoding.encoding
- the encodingtext
- the String
to be convertedbyte
representing the conversion
according to the font's encodingpublic static final byte[] convertToBytes(char char1, String encoding)
String
to a byte array according to
the font's encoding.encoding
- the encodingchar1
- the char
to be convertedbyte
representing the conversion
according to the font's encodingpublic static final String convertToString(byte[] bytes, String encoding)
String
according to
the some encoding.bytes
- the bytes to convertencoding
- the encodingString
public static boolean isPdfDocEncoding(String text)
text
only has PdfDocEncoding characters.text
- the String
to testtrue
if only PdfDocEncoding characters are presentpublic static void clearCmap(String name)
name
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.name
- the name of the cmap to clear or all the cmaps if the empty
stringpublic static void loadCmap(String name, byte[][] newline)
name
- the CJK cmap namenewline
- the sequences to be replaced by a newline in the resulting
CID. See CRLF_CID_NEWLINE
public static String convertCmap(String name, byte[] seq)
byte
array encoded as name
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/.name
- the CJK encoding nameseq
- the byte
array to be decodedpublic static String convertCmap(String name, byte[] seq, int start, int length)
byte
array encoded as name
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/.name
- the CJK encoding namestart
- the start offset in the datalength
- the number of bytes to convertseq
- the byte
array to be decodedpublic static void addExtraEncoding(String name, ExtraEncoding enc)
name
- the name of the encoding. The encoding recognition is case
insensitiveenc
- the conversion classCopyright © 2018. All rights reserved.