/// <summary>Escape special symbols or convert to hexadecimal string.</summary> /// <remarks> /// Escape special symbols or convert to hexadecimal string. /// This method don't change either /// <c>value</c> /// or /// <c>content</c> /// ot the /// <c>PdfString</c> /// . /// </remarks> /// <param name="bytes">byte array to manipulate with.</param> /// <returns>Hexadecimal string or string with escaped symbols in byte array view.</returns> protected internal virtual byte[] EncodeBytes(byte[] bytes) { if (hexWriting) { ByteBuffer buf = new ByteBuffer(bytes.Length * 2); foreach (byte b in bytes) { buf.AppendHex(b); } return(buf.GetInternalBuffer()); } else { ByteBuffer buf = StreamUtil.CreateBufferedEscapedString(bytes); return(buf.ToByteArray(1, buf.Size() - 2)); } }