Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.lowagie.text.pdf
Class PdfEncodings

    java.lang.Object
      com.lowagie.text.pdf.PdfEncodings

    public class PdfEncodings

extends Object

Supports fast encodings for winansi and PDFDocEncoding. Supports conversions from CJK encodings to CID. Supports custom encodings.

Author:
  Paulo Soares (psoares@consiste.pt)

Nested Class Summary
`private static class` | `PdfEncodings.Cp437Conversion`
`private static class` | `PdfEncodings.SymbolConversion`
`private static class` | `PdfEncodings.SymbolTTConversion`
`private static class` | `PdfEncodings.WingdingsConversion`

Field Summary
`protected static int` | `CIDCHAR`
`protected static int` | `CIDNONE`
`protected static int` | `CIDRANGE`
`(package private) static HashMap` | `cmaps`
`static byte[][]` | `CRLF_CID_NEWLINE` Assumes that '\\n' and '\\r\\n' are the newline sequences.
`(package private) static HashMap` | `extraEncodings`
`(package private) static IntHashtable` | `pdfEncoding`
`(package private) static char[]` | `pdfEncodingByteToChar`
`(package private) static IntHashtable` | `winansi`
`(package private) static char[]` | `winansiByteToChar`

Constructor Summary
`PdfEncodings()`

Method Summary
`static void` | `addExtraEncoding(String name, ExtraEncoding enc)` Adds an extra encoding.
`(package private) static void` | `breakLong(long n, int size, byte[] seqs)`
`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.
`(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 planes)`
`(package private) static void` | `encodeStream(InputStream in, ArrayList planes)`
`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.
`(package private) static void` | `readCmap(String name, ArrayList planes)`
`(package private) static char[][]` | `readCmap(String name, byte[][] newline)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### CIDNONE

    protected static final int CIDNONE

See Also:
  Constant Field Values

### CIDRANGE

    protected static final int CIDRANGE

See Also:
  Constant Field Values

### CIDCHAR

    protected static final int CIDCHAR

See Also:
  Constant Field Values

### winansiByteToChar

    static final char[] winansiByteToChar

### pdfEncodingByteToChar

    static final char[] pdfEncodingByteToChar

### winansi

    static final IntHashtable winansi

### pdfEncoding

    static final IntHashtable pdfEncoding

### extraEncodings

    static HashMap extraEncodings

### cmaps

    static final HashMap cmaps

### CRLF_CID_NEWLINE

    public static final byte[][] CRLF_CID_NEWLINE

  Assumes that '\\n' and '\\r\\n' are the newline sequences. It may not work for all CJK encodings. To be used with loadCmap().

Constructor Detail

### PdfEncodings

    public PdfEncodings()

Method Detail

### convertToBytes

    public static final byte[] convertToBytes(String text,
                                              String encoding)

  Converts a `String` to a byte array according to the font's encoding.

  Parameters:
    `encoding` - the encoding
    `text` - the `String` 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,
                                              String encoding)

  Converts a `String` to a byte array according to the font's encoding.

  Parameters:
    `encoding` - the encoding
    `char1` - the `char` to be converted
  Returns:
    an array of `byte` representing the conversion according to the font's encoding

### convertToString

    public static final String convertToString(byte[] bytes,
                                               String encoding)

  Converts a byte array to a `String` according to the some encoding.

  Parameters:
    `bytes` - the bytes to convert
    `encoding` - the encoding
  Returns:
    the converted `String`

### isPdfDocEncoding

    public static boolean isPdfDocEncoding(String text)

  Checks is `text` only has PdfDocEncoding characters.

  Parameters:
    `text` - the `String` to test
  Returns:
    `true` if only PdfDocEncoding characters are present

### clearCmap

    public static void clearCmap(String name)

  Clears the CJK cmaps from the cache. If `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.

  Parameters:
    `name` - the name of the cmap to clear or all the cmaps if the empty string

### loadCmap

    public static void loadCmap(String name,
                                byte[][] newline)

  Loads a CJK cmap to the cache with the option of associating sequences to the newline.

  Parameters:
    `name` - the CJK cmap name
    `newline` - the sequences to be replaced bi a newline in the resulting CID. See `CRLF_CID_NEWLINE`

### convertCmap

    public static String convertCmap(String name,
                                     byte[] seq)

  Converts a `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/.

  Parameters:
    `name` - the CJK encoding name
    `seq` - the `byte` array to be decoded
  Returns:
    the CID string

### convertCmap

    public static String convertCmap(String name,
                                     byte[] seq,
                                     int start,
                                     int length)

  Converts a `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/.

  Parameters:
    `name` - the CJK encoding name
    `start` - the start offset in the data
    `length` - the number of bytes to convert
    `seq` - the `byte` array to be decoded
  Returns:
    the CID string

### decodeSequence

    static String decodeSequence(byte[] seq,
                                 int start,
                                 int length,
                                 char[][] planes)

### readCmap

    static char[][] readCmap(String name,
                             byte[][] newline)
                      throws IOException

  Throws:
    `IOException`

### readCmap

    static void readCmap(String name,
                         ArrayList planes)
                  throws IOException

  Throws:
    `IOException`

### encodeStream

    static void encodeStream(InputStream in,
                             ArrayList planes)
                      throws IOException

  Throws:
    `IOException`

### breakLong

    static void breakLong(long n,
                          int size,
                          byte[] seqs)

### encodeSequence

    static void encodeSequence(int size,
                               byte[] seqs,
                               char cid,
                               ArrayList planes)

### addExtraEncoding

    public static void addExtraEncoding(String name,
                                        ExtraEncoding enc)

  Adds an extra encoding.

  Parameters:
    `name` - the name of the encoding. The encoding recognition is case insensitive
    `enc` - the conversion class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD