Beispiel #1
0
 protected String toUnicodeString(String value, boolean isHexWriting) {
   byte[] bytes = decodeStringToByte(value);
   if (isHexWriting) {
     return PdfEncodings.convertToString(bytes, "UnicodeBigUnmarked");
   } else {
     if (bytes.length >= 2 && bytes[0] == (byte) 254 && bytes[1] == (byte) 255) {
       return PdfEncodings.convertToString(bytes, PdfEncodings.UNICODE_BIG);
     } else {
       return PdfEncodings.convertToString(bytes, PdfEncodings.PDF_DOC_ENCODING);
     }
   }
 }
Beispiel #2
0
 void addRange(String from, String to, CMapObject code) {
   byte[] a1 = decodeStringToByte(from);
   byte[] a2 = decodeStringToByte(to);
   if (a1.length != a2.length || a1.length == 0) {
     throw new IllegalArgumentException("Invalid map.");
   }
   byte[] sout = null;
   if (code.isString()) {
     sout = decodeStringToByte(code.toString());
   }
   int start = a1[a1.length - 1] & 0xff;
   int end = a2[a2.length - 1] & 0xff;
   for (int k = start; k <= end; ++k) {
     a1[a1.length - 1] = (byte) k;
     String mark = PdfEncodings.convertToString(a1, null);
     if (code.isArray()) {
       List<CMapObject> codes = (ArrayList<CMapObject>) code.getValue();
       addChar(mark, codes.get(k - start));
     } else if (code.isNumber()) {
       int nn = (int) code.getValue() + k - start;
       addChar(mark, new CMapObject(CMapObject.NUMBER, nn));
     } else if (code.isString()) {
       CMapObject s1 = new CMapObject(CMapObject.HEX_STRING, sout);
       addChar(mark, s1);
       assert sout != null;
       ++sout[sout.length - 1];
     }
   }
 }