Compress pdf files using Ghostscript in Linux

Original link:


Most Linux distributions already include an open source version of Ghostscript. If not, install it as follows:

 apt install ghostscript


Suppose I want to compress the file编程珠玑.pdf :

 /usr/bin/gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -dColorImageResolution=150 -sOutputFile=编程珠玑_compressed.pdf 编程珠玑.pdf

Regarding the compression quality, we only need to modify the dPDFSETTINGS parameter:

/prepress (default) High quality (300 dpi) but larger files
/ebook Medium quality (150 dpi) moderate file size
/screen Low quality (72 dpi) but smaller output file

The ebook is more suitable in terms of file size and clarity, so I use it. Compressed by about 40%.


Refer to the Ghostscript online documentation for more parameters.

This article is reprinted from:
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment

Your email address will not be published.