Class PdfEncodings

java.lang.Object
com.itextpdf.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.
  • Field Details

    • winansiByteToChar

      static final char[] winansiByteToChar
    • pdfEncodingByteToChar

      static final char[] pdfEncodingByteToChar
    • winansi

      static final IntHashtable winansi
    • pdfEncoding

      static final IntHashtable pdfEncoding
    • extraEncodings

      static HashMap<String,ExtraEncoding> extraEncodings
  • Constructor Details

    • PdfEncodings

      public 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
    • 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