title: Chrome Packaged Apps / pdf.js
body: <p>i'm trying to develop a (offline) packaged apps with chrome 23+ which allows the user to generate and print a pdf-file. I tried various ways to achieve this, but none really works.</p>
  
  <p>Using something like this, the browser/app freezes:</p>
  
  <pre><code>window.html (includes pdf.js (http://code.google.com/p/jspdf/) and genpdf.js (see below)):
  
  ....
  &lt;browser src="about:blank" width="1024" height="768"&gt;&lt;/browser&gt;
  
  genpdf.js:
  
  var doc = new jsPDF();
  doc.text(20, 20, 'foo');
  doc.text(20, 30, 'bar');
  document.querySelector('browser').src = window.webkitURL.createObjectURL(new Blob([doc.output()], {type: 'application/pdf'}));
  </code></pre>
  
  <p>This would be my preferred way to display the generated PDF, but with the window freezing the user can't print it.</p>
  
  <p>Another way would be to save the PDF to the desktop:</p>
  
  <pre><code>chrome.fileSystem.chooseFile({type: 'saveFile'}, function(writableFileEntry) {
      writableFileEntry.createWriter(function(writer) {
        writer.onerror = function(e) {
          console.log('writeend');
        };
        writer.onwriteend = function(e) {
          console.log('writeend');
        };
        var doc = new jsPDF();
        doc.text(20, 20, 'foo');
        doc.text(20, 30, 'bar');
        writer.write(new Blob([doc.output()], {type: 'application/pdf'}));
      }, errorHandler);
  });
  </code></pre>
  
  <p>This works, but the file on the desktop is locked until the app is closed. Is there any api-call i'm missing to free the saved file?</p>
  
  <p>Thanks in advance!</p>