PdfString extends PdfPrimitiveObject { public String toUnicodeString() { if (encoding != null && encoding.length() != 0) { return getValue(); } if (content == null) { generateContent(); } byte[] b = decodeContent(); if (b.length >= 2 && b[0] == (byte) 0xFE && b[1] == (byte) 0xFF) { return PdfEncodings.convertToString(b, PdfEncodings.UNICODE_BIG); } else if (b.length >= 3 && b[0] == (byte)0xEF && b[1] == (byte)0xBB && b[2] == (byte)0xBF) { return PdfEncodings.convertToString(b, PdfEncodings.UTF8); } else { return PdfEncodings.convertToString(b, PdfEncodings.PDF_DOC_ENCODING); } } PdfString(String value, String encoding);  PdfString(String value);  PdfString(byte[] content); protected  PdfString(byte[] content, boolean hexWriting); private  PdfString(); @Override byte getType(); boolean isHexWriting(); PdfString setHexWriting(boolean hexWriting); String getValue(); String getEncoding(); String toUnicodeString(); byte[] getValueBytes(); @Override boolean equals(Object o); @Override String toString(); @Override int hashCode(); void markAsUnencryptedObject();  }
@Test public void testUnicodeString() { String unicode = "Привет!"; PdfString string = new PdfString(unicode); Assert.assertNotEquals(unicode, string.toUnicodeString()); }