iGoX's links
Nuage de tags
Mur d'images
Quotidien
Plugins
  • ► Jouer les vidéos
Flux RSS
  • Flux RSS
  • Daily Feed
  • Weekly Feed
  • Monthly Feed
Filtres

Liens par page

  • 20 links
  • 50 links
  • 100 links

Filtres

Untagged links
How to Compress PDF files in Command Line using Ghostscript /shaare/QN-5Cw
Thu Jun 1 17:17:36 2023
QRCode
archive.org

Reduce PDF file size in Linux command line

You can use Ghostscript command line tool for compressing a PDF file. Most Linux distributions include the open source version of Ghostscript already. However, you can still try to install it just to make sure.

On Debian/Ubuntu based distributions, use the following command to install Ghostscript:

sudo apt install ghostscript

MacOS with Brew:

brew install ghostscript

Now that you have made sure that Ghostscript is installed, you can use the following command to reduce the size of your PDF file:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -dNOPAUSE -dQUIET -dBATCH -sOutputFile=compressed_PDF_file.pdf input_PDF_file.pdf

In the above command, you should add the correct path of the input and out PDF file.

The command looks scary and confusing. I advise copying and pasting most of it. What you need to know is the dPDFSETTINGS parameter. This is what determines the compression level and thus the quality of your compressed PDF file.

dPDFSETTINGS Description
/prepress (default) Higher quality output (300 dpi) but bigger size
/ebook Medium quality output (150 dpi) with moderate output file size
/screen Lower quality output (72 dpi) but smallest possible output file size
pdf commandLine
678 links, including 6 private
Shaarli - The personal, minimalist, super-fast, database free, bookmarking service par la communauté Shaarli - Theme by kalvn