Open krupalimakadiya opened 2 years ago
After spending lots of time found :roll_eyes: fixes like compress PDF via ghost script using shell.
First npm install shelljs
; // (^0.8.5)
then, `const shell = require('shelljs');
const uncompressed_inputFile = '../input.pdf'; // directory path with file name const compressed_outputFile = '../output.pdf' // directory path with file name
shell.exec('gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.2 -dPDFSETTINGS=/prepress -dColorImageResolution=144 -dNOPAUSE -dQUIET -dBATCH -sPAPERSIZE=a4 -sOutputFile=${compressed_outputFile} ${uncompressed_inputFile}'); `
for more options of ghostscript : https://www.ghostscript.com/doc/current/VectorDevices.htm#PDF -> (7.4 PDF file output).
P.S: Using above code i reduced PDF size from 3.0MB to 731KB.
when i embedded 'calibri' font in my PDF, Surprisely increase size of PDF 900KB to 3MB, i'dont know why it's happening if you have solution recommended here,