Linux - Compressing PDF Documents In Linux

Using ghostscript

$ gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=out.pdf in.pdf

Note the term `-dPDFSETTINGS=/screen` in the command. You can actually tweak this option to fiddle with the output PDF’s size. Below is a table of the different -dPDFSETTINGS options and what they do:

-dPDFSETTINGS options What does it do?
——————————————- —————————————————————-
-dPDFSETTINGS=/screen Output files will have up to 72 DPI.
-dPDFSETTINGS=/ebook Output files will have up to 150 DPI.
-dPDFSETTINGS=/prepress Output files will have up to 300 DPI.
-dPDFSETTINGS=/printer Output files will have up to 300 DPI, and ready for printing.
-dPDFSETTINGS=/default (Usually prepress) Depends on which of the above options is assigned as “default.”

Out of the box, `/prepress` is the default.

Using shrinkpdf

$ shrinkpdf in.pdf > out.pdf

Links to this note