First, find a way to install the Ghostscript binary on their Installation docs page. In my case, Ghostscript came pre-installed on Manjaro, so I didn't have to do anything to get it :)
Then run this command from the terminal:
gs -sDEVICE=pdfwrite \
-dCompatibilityLevel=1.4 \
-dPDFSETTINGS=<my-compression-preset> \
-dNOPAUSE \
-dQUIET \
-dBATCH \
-sOutputFile=my-compressed-file.pdf \
my-uncompressed-file.pdf
where <my-compression-preset>
must be replaced by one of the following values as per their documentation:
/screen
selects low-resolution output similar to the Acrobat Distiller (up to version X) “Screen Optimized” setting./ebook
selects medium-resolution output similar to the Acrobat Distiller (up to version X) “eBook” setting./printer
selects output similar to the Acrobat Distiller “Print Optimized” (up to version X) setting./prepress
selects output similar to Acrobat Distiller “Prepress Optimized” (up to version X) setting./default
selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file.I recommend to try out the different presets to find out if the quality degradation vs size-reduction is working for you.
For me, the first time I used this I went with the /prepress
preset and it was good enough to bypass the file uploader form constraint I was trying to circumvent.
Taken from: It's FOSS
Reference: Ghostscript docs