title: How to get byte-array data from servlet to pdf.js
body: <p>How can I get this:</p>
  
  <pre><code>File file = new File(doneDir + "\\" + batchName + "\\" + fileName);
  byte[] by = new byte[(int) file.length()];
  FileInputStream fis = new FileInputStream(file);
  fis.read(by);
  fis.close();
  
  response.setContentType("application/pdf");
  response.setHeader("Content-disposition", "attachment; filename=TheDocument." + "pdf");
  response.getOutputStream().write(by);
  response.getOutputStream().flush();
  response.getOutputStream().close();
  </code></pre>
  
  <p>From my servlet either doGet or doPost to the pdf.js function:</p>
  
  <pre><code>var data = (byte array returned from servlet)
  PDFJS.getDocument(data).then(function(pdf) {});
  </code></pre>