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.


For jsPDF you can do:

<script language="javascript" src=">

You can install the library with bower too:

bower install jspdf


And for jsZIP you can add

<script language="javascript" src=""> </script>

you can install with bower using:

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:

$(function() {
    var doc = new jsPDF();

		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, "");

If you want to test it online: