title: jspdf in Chrome packaged app : document.writeln() not available
body: <p>I'm developing a Chrome App, and i would like to allow the user to export as a PDF a few HTML Table.
  I made some research and i found jsPdf as the plugin i needed.
  And now comes my issue. jsPDF and its function "fromHTML" use the method "document.writeln()" which is not available in Chrome Packaged App.</p>
  
  <p><strong>"Uncaught Error: document.writeln() is not available in packaged apps."</strong></p>
  
  <p><a href="http://i.stack.imgur.com/HF2Nz.png" rel="nofollow">Console error as jspdf tries to use document.writeln()</a></p>
  
  <p>I've made a ton a research over the internet, and found that there are some ways to counter that issue, by adding some "document.create". But while i don't know how jspdf works, i don't really know what to create.</p>
  
  <p>There is the part of jspdf that's causing the issue : </p>
  
  <pre><code>var $frame, $hiddendiv, framename,  visuallyhidden;
  
  framename = "jsPDFhtmlText" + Date.now().toString() + (Math.random() * 1000).toFixed(0);
  
  visuallyhidden = "position: absolute !important;" + "clip: rect(1px 1px 1px 1px); /* IE6, IE7 */" + "clip: rect(1px, 1px, 1px, 1px);" + "padding:0 !important;" + "border:0 !important;" + "height: 1px !important;" + "width: 1px !important; " + "top:auto;" + "left:-100px;" + "overflow: hidden;";
  
  $hiddendiv = document.createElement('div');
  $hiddendiv.style.cssText = visuallyhidden;
  $hiddendiv.innerHTML = "&lt;iframe style=\"height:1px;width:1px\" name=\"" + framename + "\" /&gt;";
  document.body.appendChild($hiddendiv);
  
  $frame = window.frames[framename];
  $frame.document.open();
  $frame.document.writeln(element);//This causes "Uncaught Error: document.writeln() is not available in packaged apps."
  $frame.document.close();
  return $frame.document.body;
  </code></pre>
  
  <p>And here is my call of the jspdf library, maybe i made a mistake here :</p>
  
  <pre><code>$('#exportMonth').click(function(){
      console.log(TAG + "Starting rendering as PDF");
  
      var doc = new jsPDF();
      specialElementHandlers = {
          // element with id of "bypass" - jQuery style selector
          // here i've nothing to bypass, so nothing is 'bypassme'
          '#bypassme': function(element, renderer) {
              // true = "handled elsewhere, bypass text extraction"
              return true
          }
      };
      //the id 'month' refers to a div containing a html Table
      doc.fromHTML($('#month').html(),15,15 ,{
          width:600,
          elementHandler:specialElementHandlers
      });
      doc.save('Tst.pdf');
  
      console.log(TAG + "Should be done");
  });
  </code></pre>
  
  <p>I'll continue my research but i'm really lost rigth now, i really need your help ! </p>
  
  <p>I may have forgotten to say some things, just let me know and i'll try to be as quick as possible fixing that.</p>
  
  <p>Many thanks !</p>