title: UTF-8 encoding with ByteArrayOutputStream
body: <p>I am having issues with the character encoding for non english characters. Here I am using itext library to generate the pdf. </p>
  
  <pre><code>ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
  Document document = new Document();
  document.setMargins(-50.0f, -50.0f, 15.0f, 0.0f);
  PdfWriter.getInstance(document, byteArrayOutputStream);
  document.open();
  </code></pre>
  
  <h2>-----</h2>
  
  <pre><code>myObj.setByteArrayInputStream(new byteArrayInputStream(byteArrayOutputStream.toByteArray()));
  </code></pre>
  
  <p>I tried with the following code </p>
  
  <pre><code>myObj.setByteArrayInputStream(new ByteArrayInputStream(byteArrayOutputStream.toString("UTF-8").getBytes()));
  </code></pre>