Computers Files

How to Reduce PDF File Size in Linux

Reducing the size of a PDF file on Linux can be achieved using various tools. One of the most commonly used tools for this purpose is Ghostscript. Here’s how you can use Ghostscript to reduce the size of a PDF file:

  1. Install Ghostscript:If you don’t have Ghostscript installed, you can usually install it via your distribution’s package manager. For example:
    • On Debian/Ubuntu:
      sudo apt update
      sudo apt install ghostscript
    • On Fedora:
      sudo dnf install ghostscript
    • On CentOS/Red Hat:
      sudo yum install ghostscript
    • On openSUSE:
      sudo zypper install ghostscript
    • On Arch Linux:
      sudo pacman -S ghostscript
  2. Reduce PDF Size:Use the following command to compress your PDF:
    gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
    • input.pdf is the name of the original PDF file.
    • output.pdf is the name of the compressed PDF file.
    • The -dPDFSETTINGS option determines the quality:
      • /screen: low resolution, lowest output size (72 dpi images).
      • /ebook: medium resolution, medium output size (150 dpi images).
      • /printer: high quality, large output size (300 dpi images).
      • /prepress: high quality, large output size (like /printer, but optimized for print production).

    Choose the setting that best fits your needs. For example, if you’re looking for a balance between file size and quality, /ebook is often a good choice.

  3. Verify the Output:After running the command, make sure to open output.pdf and check its quality. Adjust the -dPDFSETTINGS option as needed if you’re not satisfied with the result.

Besides Ghostscript, there are other tools and software available on Linux for PDF manipulation, such as pdftk, pdfjam, and more. However, Ghostscript is one of the most versatile for compression tasks.

Leave a Reply

Your email address will not be published. Required fields are marked *