Javascript HTML2PDF.js Example to Compress Size of Output PDF Document By Reducing Scale & Quality of PDF in Browser Using HTML5

 

 

Decreasing scale property decrease quality, size

 

You can use JsZip to compress the PDF, then generate a zip folder with your current PDF inside.
And you have to use the saveAs() methods from file-saver module.

here is what it look.

zip.file( "myFile.pdf", html2pdf(element, opt) .from(element) .set(opt) .output() ); zip .generateAsync({ type: "blob", compression: "DEFLATE", compressionOptions: { level: 9 } }) .then(res => saveAs(res, "myFolder.zip"));

 

 

 

Leave a Reply