Class PDFDocCharsetEncoder

java.lang.Object
java.nio.charset.CharsetEncoder
com.sun.pdfview.PDFDocCharsetEncoder

public class PDFDocCharsetEncoder extends CharsetEncoder
Encodes into a PDFDocEncoding representation. Note that only 256 characters (if that) are represented in the PDFDocEncoding, so users should be prepared to deal with unmappable character exceptions.
See Also:
  • "PDF Reference version 1.7, Appendix D"
  • Field Details

    • IDENT_PDF_DOC_ENCODING_MAP

      static final boolean[] IDENT_PDF_DOC_ENCODING_MAP
      For each character that exists in PDFDocEncoding, identifies whether the byte value in UTF-16BE is the same as it is in PDFDocEncoding
    • EXTENDED_TO_PDF_DOC_ENCODING_MAP

      static final Map<Character,Byte> EXTENDED_TO_PDF_DOC_ENCODING_MAP
      For non-identity encoded characters, maps from the character to the byte value in PDFDocEncoding. If an entry for a non-identity coded character is absent from this map, that character is unmappable in the PDFDocEncoding.
  • Constructor Details

    • PDFDocCharsetEncoder

      public PDFDocCharsetEncoder()
  • Method Details

    • isIdentityEncoding

      public static boolean isIdentityEncoding(char ch)
      Identify whether a particular character preserves the same byte value upon encoding in PDFDocEncoding
      Parameters:
      ch - the character
      Returns:
      whether the character is identity encoded
    • encodeLoop

      protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out)
      Specified by:
      encodeLoop in class CharsetEncoder
    • isLegalReplacement

      public boolean isLegalReplacement(byte[] repl)
      Overrides:
      isLegalReplacement in class CharsetEncoder