title: Is it possible to convert byte array/stream to files such as Word,Excel, PDF in JavaScript
body: <p>I have a query regarding file operations using JavaScript- </p>
  
  <p>Scenario - My JS function calls a wcf service which returns the file content in the form of byte array or stream and the mime type. This byte array/stream needs to be converted to a file and which will be downloaded on  user's machine.<br/>
  <strong><a href="https://stackoverflow.com/questions/27946228/file-download-a-byte-array-as-a-file-in-javascript-extjs">Reference code</a></strong> - </p>
  
  <pre><code>var arr = "This is test content";
  var byteArray = new Uint8Array(arr);
  var a = window.document.createElement('a');
  
  a.href = window.URL.createObjectURL(new Blob([byteArray], {
      type: 'text/plain'
  }));
  a.download = "Test";
  
  document.body.appendChild(a);
  a.click();
  
  document.body.removeChild(a);
  </code></pre>
  
  <p>The code works for only text files. Files with mime type other than text are corrupted.
  I understand that file operations are severly restricted at client side, but just to confirm - Is there anyway to convert byte array/stream to files such as Word,Excel, PDF and etc ? </p>