I've successfully created a zip file with a PDF init.
But when i try to open the file it says the file is corrupted.
var zip = new JSZip();
var count = 0;
var zipFilename = "zipFilename.zip";
var urls = [];
var filenames = [];
var groupHolder = $(target).closest('.group-downloads');
var productDownloads = $(groupHolder).children('.group-single-download');
$(productDownloads).each(function () {
urls.push(($(this).data('downloadUrl')));
filenames.push(($(this).data('filename')));
});
console.log(urls);
$(urls).each(function(url){
var filename = filenames[count];
// loading a file and add it in a zip file
JSZipUtils.getBinaryContent(url, function (err, data) {
if(err) {
throw err; // or handle the error
}
zip.file(filename, data, {binary:true});
count++;
// Create zip if there are no more items left.
if (count == urls.length) {
zip.generateAsync({type:'blob'}).then(function(content) {
saveAs(content, zipFilename);
});
}
});
});
Hi there,
I've successfully created a zip file with a PDF init. But when i try to open the file it says the file is corrupted.
The PDF url on my server is: https://artiteq.local/wp-content/uploads/2019/05/ARTITEQ_IMAGINE-IT-_TECHNICAL-SHEET.pdf
Am i doing something wrong?