I want zip a pdf or some other format like excel, ppt etc using zip.js.
How to zip this format in zip.js? I have written but I failed in generating the zip file. My requirement is to download the zip file when I click the download button. How to do this? I am completely stuck in generating the zip file.
My code is as below
<body>
<a id ='file' href="http://www.brainlens.org/content/newsletters/Spring%202013.pdf" type="application/pdf" name="Sample.pdf">Sample.pdf</a>
<input id="button" type="button" value="Create Zip"></input>
</body>
<script>
var FILENAME = document.getElementById('file').name;//"sample.pdf"
var URL = document.getElementById('file').href;//"sample.pdf"
var zipFs = new zip.fs.FS();
function zipPDF() {
zipFs.root.addHttpContent(FILENAME, URL);
}
function create_zip(){
zipPDF();
}
var btn = document.getElementById('button');
btn.addEventListener("click", create_zip, false);
</script>