Create Zip files from Javascript

Ok. This is really a test of two great libraries.
jsPDF (Amazing you can create now PDFs in the browser) and jsZIP for creating zip files.

Using these libraries is as simple as including just one script tag.

jsPDF

For jsPDF you can do:

<script language="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.4/jspdf.debug.js>  
</script>  

You can install the library with bower too:

bower install jspdf  

jsZIP

And for jsZIP you can add

<script language="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.js"> </script>  

you can install with bower using:

https://stuk.github.io/jszip/  

Ok now to our tasks. So the idea was. Can be create a zip from javascript. And yes we can. The following example creates a PDF and then adds it to a zip file:

<script>  
$(function() {
    var doc = new jsPDF();

        doc.setFontSize(40);
        doc.text(35, 25, "Cultivo una rosa blanca\r\nEn junio como en enero\r\npara el amigo sincero que me da su mano franca\r\ny para el cruel que me arranca\r\nel corazon con que vivo...\r\ncardo ni ortiga cultivo\r\ncultivo una rosa blanca");

 var zip = new JSZip();
  zip.file("Poem.pdf", doc.output());
  zip.generateAsync({ type: "blob" })
  .then(function (content) {
      saveAs(content, "example.zip");
  });
})
</script>  

If you want to test it online:

https://jsfiddle.net/Orellabac/uaekwmna/