Package com.aowagie.text.pdf
Class PdfEncodings
- java.lang.Object
-
- com.aowagie.text.pdf.PdfEncodings
-
final class PdfEncodings extends java.lang.Object
Supports fast encodings for winansi and PDFDocEncoding. Supports conversions from CJK encodings to CID. Supports custom encodings.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
PdfEncodings.Cp437Conversion
private static class
PdfEncodings.SymbolConversion
private static class
PdfEncodings.SymbolTTConversion
private static class
PdfEncodings.WingdingsConversion
-
Field Summary
Fields Modifier and Type Field Description private static int
CIDCHAR
private static int
CIDNONE
private static int
CIDRANGE
private static java.util.HashMap
cmaps
private static java.util.HashMap
extraEncodings
private static IntHashtable
pdfEncoding
private static char[]
pdfEncodingByteToChar
(package private) static IntHashtable
winansi
private static char[]
winansiByteToChar
-
Constructor Summary
Constructors Constructor Description PdfEncodings()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
addExtraEncoding(java.lang.String name, ExtraEncoding enc)
Adds an extra encoding.private static void
breakLong(long n, int size, byte[] seqs)
private static java.lang.String
convertCmap(java.lang.String name, byte[] seq, int start, int length)
Converts abyte
array encoded asname
to a CID string.static byte[]
convertToBytes(char char1, java.lang.String encoding)
Converts aString
to a byte array according to the font's encoding.static byte[]
convertToBytes(java.lang.String text, java.lang.String encoding)
Converts aString
to a byte array according to the font's encoding.static java.lang.String
convertToString(byte[] bytes, java.lang.String encoding)
Converts a byte array to aString
according to the some encoding.private static java.lang.String
decodeSequence(byte[] seq, int start, int length, char[][] planes)
private static void
encodeSequence(int size, byte[] seqs, char cid, java.util.ArrayList planes)
private static void
encodeStream(java.io.InputStream in, java.util.ArrayList planes)
static boolean
isPdfDocEncoding(java.lang.String text)
Checks istext
only has PdfDocEncoding characters.private static char[][]
readCmap(java.lang.String name, byte[][] newline)
private static void
readCmap(java.lang.String name, java.util.ArrayList planes)
-
-
-
Field Detail
-
CIDNONE
private static final int CIDNONE
- See Also:
- Constant Field Values
-
CIDRANGE
private static final int CIDRANGE
- See Also:
- Constant Field Values
-
CIDCHAR
private static final int CIDCHAR
- See Also:
- Constant Field Values
-
winansiByteToChar
private static final char[] winansiByteToChar
-
pdfEncodingByteToChar
private static final char[] pdfEncodingByteToChar
-
winansi
static final IntHashtable winansi
-
pdfEncoding
private static final IntHashtable pdfEncoding
-
extraEncodings
private static java.util.HashMap extraEncodings
-
cmaps
private static final java.util.HashMap cmaps
-
-
Method Detail
-
convertToBytes
public static final byte[] convertToBytes(java.lang.String text, java.lang.String encoding)
Converts aString
to a byte array according to the font's encoding.- Parameters:
encoding
- the encodingtext
- theString
to be converted- Returns:
- an array of
byte
representing the conversion according to the font's encoding
-
convertToBytes
public static final byte[] convertToBytes(char char1, java.lang.String encoding)
Converts aString
to a byte array according to the font's encoding.- Parameters:
encoding
- the encodingchar1
- thechar
to be converted- Returns:
- an array of
byte
representing the conversion according to the font's encoding
-
convertToString
public static final java.lang.String convertToString(byte[] bytes, java.lang.String encoding)
Converts a byte array to aString
according to the some encoding.- Parameters:
bytes
- the bytes to convertencoding
- the encoding- Returns:
- the converted
String
-
isPdfDocEncoding
public static boolean isPdfDocEncoding(java.lang.String text)
Checks istext
only has PdfDocEncoding characters.- Parameters:
text
- theString
to test- Returns:
true
if only PdfDocEncoding characters are present
-
convertCmap
private static java.lang.String convertCmap(java.lang.String name, byte[] seq, int start, int length)
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 namestart
- the start offset in the datalength
- the number of bytes to convertseq
- thebyte
array to be decoded- Returns:
- the CID string
-
decodeSequence
private static java.lang.String decodeSequence(byte[] seq, int start, int length, char[][] planes)
-
readCmap
private static char[][] readCmap(java.lang.String name, byte[][] newline) throws java.io.IOException
- Throws:
java.io.IOException
-
readCmap
private static void readCmap(java.lang.String name, java.util.ArrayList planes) throws java.io.IOException
- Throws:
java.io.IOException
-
encodeStream
private static void encodeStream(java.io.InputStream in, java.util.ArrayList planes) throws java.io.IOException
- Throws:
java.io.IOException
-
breakLong
private static void breakLong(long n, int size, byte[] seqs)
-
encodeSequence
private static void encodeSequence(int size, byte[] seqs, char cid, java.util.ArrayList planes)
-
addExtraEncoding
private static void addExtraEncoding(java.lang.String name, ExtraEncoding enc)
Adds an extra encoding.- Parameters:
name
- the name of the encoding. The encoding recognition is case insensitiveenc
- the conversion class
-
-