How to compress a pdf in Linux

Stanley Meng
1 min readDec 13, 2019

--

There are lots of online free tools to do that. But personally I don’t want to upload certain pdf files which contain privacy info to the web tools.

Luckily, Linux has an amazing tool to compress the pdf file as long as you don’t need those advanced feature, this trick should be good enough.

The credit goes to https://askubuntu.com/a/256449.

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=compressed_inpurt.pdf input.pdf
  • -dPDFSETTINGS=/screen lower quality, smaller size. (72 dpi)
  • -dPDFSETTINGS=/ebook for better quality, but slightly larger pdfs. (150 dpi)
  • -dPDFSETTINGS=/prepress output similar to Acrobat Distiller "Prepress Optimized" setting (300 dpi)
  • -dPDFSETTINGS=/printer selects output similar to the Acrobat Distiller "Print Optimized" setting (300 dpi)
  • -dPDFSETTINGS=/default selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file

Another situation is that you want to merge several images to a pdf, but they are huge. Try another one:

convert -resize 2500x2500 p0.jpg p1.jpg  p2.jpg  p3.jpg  p4.jpg compressed_sdz.pdf

You can get ‘convert’ by:

sudo apt-get install imagemagick

--

--

No responses yet