Class PdfEncodings


  • public class PdfEncodings
    extends java.lang.Object
    Supports fast encodings for winansi and PDFDocEncoding. Supports conversions from CJK encodings to CID. Supports custom encodings.
    Author:
    Paulo Soares
    • Constructor Summary

      Constructors 
      Constructor Description
      PdfEncodings()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addExtraEncoding​(java.lang.String name, ExtraEncoding enc)
      Adds an extra encoding.
      static byte[] convertToBytes​(char char1, java.lang.String encoding)
      Converts a String to a byte array according to the font's encoding.
      static byte[] convertToBytes​(java.lang.String text, java.lang.String encoding)
      Converts a String 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 a String according to the some encoding.
      static boolean isPdfDocEncoding​(java.lang.String text)
      Checks is text only has PdfDocEncoding characters.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PdfEncodings

        public PdfEncodings()
    • Method Detail

      • convertToBytes

        public static final byte[] convertToBytes​(java.lang.String text,
                                                  java.lang.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,
                                                  java.lang.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 java.lang.String convertToString​(byte[] bytes,
                                                             java.lang.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​(java.lang.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​(java.lang.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