node-zip icon indicating copy to clipboard operation
node-zip copied to clipboard

PDF file corrupted when zipped and downloaded

Open josephchan91 opened this issue 7 years ago • 0 comments

I'm using PDFKit to generate a PDF file. I want to zip it into a folder together with an excel file. When I download the zip file, I'm getting a 0kb pdf file. The excel file works fine though.

const zip = new require("node-zip")();
zip.file(pdfFilePath, fs.readFileSync(`tmp/${pdfFilePath}`));
const zipData = zip.generate({ base64: false, compression: "DEFLATE" });
const zipFilePath = `tmp/myzipfile.zip`;
fs.writeFileSync(zipFilePath, zipData, "binary");

Any suggestions?

josephchan91 avatar Jul 18 '18 11:07 josephchan91