pdfmin
pdfmin is a CLI tool to compress PDF using GhostScript.
Requirements
GhostScript must be installed on your device !
Install GhostScript on UNIX
sudo apt-get install -y ghostscript
Install GhostScript on Windows
Go to https://ghostscript.com/releases/gsdnld.html and download the installer corresponding to your Windows version.
Install GhostScript using the installer.
Usage
Compress only one PDF
npx pdfmin ./myFile.pdf
Compress multiple specific PDF
npx pdfmin ./myFile.pdf ./myFile2.pdf
Compress all PDF in a folder
npx pdfmin ./myFolder/
Compress all PDF in multiple folders
npx pdfmin ./myFolder/ ./myFolder2/