Class PdfEncodings

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

final class PdfEncodings extends Object
Supports fast encodings for winansi and PDFDocEncoding. Supports conversions from CJK encodings to CID. Supports custom encodings.
  • Field Details

    • CIDNONE

      private static final int CIDNONE
      See Also:
    • CIDRANGE

      private static final int CIDRANGE
      See Also:
    • CIDCHAR

      private static final int CIDCHAR
      See Also:
    • 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 HashMap extraEncodings
    • cmaps

      private static final HashMap cmaps
  • Constructor Details

    • PdfEncodings

      PdfEncodings()
  • Method Details

    • convertToBytes

      public static final byte[] convertToBytes(String text, String encoding)
      Converts a String to a byte array according to the font's encoding.
      Parameters:
      text - the String to be converted
      encoding - the encoding
      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:
      char1 - the char to be converted
      encoding - the encoding
      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
    • convertCmap

      private 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
      seq - the byte array to be decoded
      start - the start offset in the data
      length - the number of bytes to convert
      Returns:
      the CID string
    • decodeSequence

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

      private static char[][] readCmap(String name, byte[][] newline) throws IOException
      Throws:
      IOException
    • readCmap

      private static void readCmap(String name, ArrayList planes) throws IOException
      Throws:
      IOException
    • encodeStream

      private static void encodeStream(InputStream in, ArrayList planes) throws IOException
      Throws:
      IOException
    • breakLong

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

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

      private 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