title: Cordova write PDF to file
body: <p>I whant to write a Cordova App for BlackBerry10 that can write a PDF file (from a SharePointWebservice) and show it.</p>
  
  <p>The PDF is transmitted from a  ASP.NET Webservice as byte[] using</p>
  
  <pre><code>byte[] result = spFile.OpenBinary();
  </code></pre>
  
  <p>I'm able to access the file with JSON. This works fine.
  To transform the data fromm JSON to usable format I use the following code:</p>
  
  <pre><code>var binary = '';
  var bytes = new Uint8Array(data.d);
  var len = bytes.byteLength;
  for (var i = 0; i &lt; len; i++) {
      binary += String.fromCharCode(data.d[i]);
  }
  </code></pre>
  
  <p>binary is now looking like that:</p>
  
  <p>%PDF-1.5%µµµµ 1 0 obj ... startxref 103423 %%EOF</p>
  
  <p>Here is the Code to write it to a file using cordova-plugin-file.</p>
  
  <pre><code>var blob = new Blob([binary], { type: 'application/pdf' });
  fileWriter.write(blob);
  </code></pre>
  
  <p>It works fine for txt files, but when I try to write the PDF file I get an empty document.
  I have also tryed window.btoa(binary) instead of just using binary.</p>
  
  <p>Any ideas what ho to create the data blob, or which format to use?</p>