Ubuntu – How to reduce the size of a pdf file

compressionghostscriptpdf

I'm looking for a way in Ubuntu to reduce the size of a pdf (by reducing the quality of the images).

I know that this can be done in Ghostscript by typing the following command in terminal:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

The problem is that I can't specify the quality with any accuracy. The parameter -dPDFSETTINGS=/screen is the one that decides the quality; but the alternatives are quite rigid (for example it is possible to do -dPDFSETTINGS=/ebook for slightly better quality).

I'm looking for a way to reduce the size of a pdf in a way that allows me to specify the desired quality numerically.

Best Answer

I was able to make a slight variation on your command successful using the -r300 option from @drN The -r option allows you to set the output resolution in the pdf as well as png.

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default \
    -dNOPAUSE -dQUIET -dBATCH -dDetectDuplicateImages \
    -dCompressFonts=true -r150 -sOutputFile=output.pdf input.pdf