Class PDFDocEncoding


  • public final class PDFDocEncoding
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void convertUTF16ToPDFDocEncoding​(byte[] input, EncodedData<char[]> encInfo)
      Tries to convert the UTF-16 bytes passed to PDF Doc encoding.
      static char[] decode​(byte[] bytes, int start, int length)
      PDFDocEncoding-encoded bytes to string conversion.
      static byte[] encode​(java.lang.String s)
      String to PDFDocEncoding-encoded bytes conversion.
      static void encToUCSStrInternal​(EncodedData<char[]> inputEncInfo, EncodedData<byte[]> outputEncInfo)
      This method converts PDF Doc encoded data to UCS format.
      static byte[] fromEscapeString​(java.lang.String str)
      Converts escaped string to a byte array.
      static byte[] fromUnicodeString​(java.lang.String uniStr)
      Converts a unicode string to byte array.
      static byte[] fromUnicodeString​(java.lang.String uniStr, boolean utf16)  
      static boolean isPDFDocEncoding​(java.lang.String uniStr)  
      static boolean isUnicode​(java.lang.String uniStr)
      Returns true if passed string represents unicode, else false.
      static java.lang.String toAcrobatString​(byte[] bytes)
      Converts byte array to same string format as Acrobat does.
      static java.lang.String toAcrobatString​(byte[] bytes, int start, int length)
      Converts byte array to same string format as Acrobat does.
      static java.lang.String toEscapeString​(byte[] bytes, int start, int length)
      Converts the byte array to escaped string.
      static java.lang.String toUnicodeString​(byte[] bytes)
      Converts byte array to unicode string.
      static java.lang.String toUnicodeString​(byte[] bytes, int start, int length)
      Make a Unicode string from a byte array
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • toAcrobatString

        public static java.lang.String toAcrobatString​(byte[] bytes)
        Converts byte array to same string format as Acrobat does.
      • toAcrobatString

        public static java.lang.String toAcrobatString​(byte[] bytes,
                                                       int start,
                                                       int length)
        Converts byte array to same string format as Acrobat does.
      • toUnicodeString

        public static java.lang.String toUnicodeString​(byte[] bytes)
                                                throws PDFParseException
        Converts byte array to unicode string.
        Throws:
        PDFParseException
      • toUnicodeString

        public static java.lang.String toUnicodeString​(byte[] bytes,
                                                       int start,
                                                       int length)
                                                throws PDFParseException
        Make a Unicode string from a byte array
        Throws:
        PDFParseException
      • toEscapeString

        public static java.lang.String toEscapeString​(byte[] bytes,
                                                      int start,
                                                      int length)
        Converts the byte array to escaped string.
      • fromEscapeString

        public static byte[] fromEscapeString​(java.lang.String str)
        Converts escaped string to a byte array.
      • fromUnicodeString

        public static byte[] fromUnicodeString​(java.lang.String uniStr)
        Converts a unicode string to byte array.
      • fromUnicodeString

        public static byte[] fromUnicodeString​(java.lang.String uniStr,
                                               boolean utf16)
      • decode

        public static char[] decode​(byte[] bytes,
                                    int start,
                                    int length)
                             throws java.nio.charset.CharacterCodingException
        PDFDocEncoding-encoded bytes to string conversion.
        Throws:
        java.nio.charset.CharacterCodingException - the byte stream is not a legal encoding.
      • encode

        public static byte[] encode​(java.lang.String s)
                             throws java.nio.charset.CharacterCodingException
        String to PDFDocEncoding-encoded bytes conversion.
        Throws:
        java.nio.charset.CharacterCodingException - the input string contains a characters which is not in PDFDocEncoding.
      • isUnicode

        public static boolean isUnicode​(java.lang.String uniStr)
        Returns true if passed string represents unicode, else false.
      • isPDFDocEncoding

        public static boolean isPDFDocEncoding​(java.lang.String uniStr)
      • convertUTF16ToPDFDocEncoding

        public static void convertUTF16ToPDFDocEncoding​(byte[] input,
                                                        EncodedData<char[]> encInfo)
        Tries to convert the UTF-16 bytes passed to PDF Doc encoding. This method copies the logic of ASTextGetPDTextCopy method in ASText.cpp file of Acrobat.
        Parameters:
        input -
        encInfo - This is the encoding information of the output.
      • encToUCSStrInternal

        public static void encToUCSStrInternal​(EncodedData<char[]> inputEncInfo,
                                               EncodedData<byte[]> outputEncInfo)
        This method converts PDF Doc encoded data to UCS format. Logic is copied from EncToUCSStrInternal method in PDConvrt.cpp file of Acrobat.
        Parameters:
        inputEncInfo -
        outputEncInfo -