title: PDFJS and PDF encoding
body: <p>We are implementing PDFJS to render pdf files on a website.</p>
  
  <p>When trying to initiate a PDFdocument/Viewer as an arrayBuffer, we get al sorts of errors and the file is not rendered.
  When opening the same file in the viewer from url (DEFAULT_URL variable), the file renders fine.</p>
  
  <p>There are however some files that do render as streams. Comparing these files in notepad shows they have different encoding/characters.</p>
  
  <p>This piece of code is used to open the file in the viewer:</p>
  
  <pre><code>function rawStringToBuffer( str ) {
      var idx, len = str.length, arr = new Array( len );
      for ( idx = 0 ; idx &lt; len ; ++idx ) {
          arr[ idx ] = str.charCodeAt(idx) &amp; 0xFF;
      }
      return new Uint8Array( arr ).buffer;
  }
  
  function readSingleFile(e) {
    var file = e.target.files[0];
    if (!file) {
      return;
    }
    var reader = new FileReader();
    reader.onload = function(e) {
      var contents = e.target.result;
  
      var uint8array = rawStringToBuffer(contents);
  
      pdfjsframe.contentWindow.PDFViewerApplication.open(uint8array,0);
  
      };
      reader.readAsText(file);
  }
  </code></pre>
  
  <p><a href="http://www.svdw.be/test/test.pdf" rel="nofollow noreferrer">test.pdf</a> helloworld pdf which is not rendered with code above.</p>
  
  <p><a href="https://i.stack.imgur.com/QVo87.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QVo87.jpg" alt="file content in notepad"></a></p>
  
  <p><a href="http://www.svdw.be/test/test2.pdf" rel="nofollow noreferrer">test2.pdf</a> helloworld pdf which does rendered with code above.</p>
  
  <p><a href="https://i.stack.imgur.com/RrlgN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RrlgN.jpg" alt="enter image description here"></a></p>
  
  <p>The behaviour is not browser dependent. The build is b15f335.</p>
  
  <p>Is there something with the code or default configuration of the viewer so that test.pdf can not be rendered by the viewer?</p>