Skip to content

Latest commit

 

History

History
74 lines (64 loc) · 3.03 KB

File metadata and controls

74 lines (64 loc) · 3.03 KB

PDF COMPressor

This script is meant to simplify ghostscript syntax and also to have a convenient and practical solution for PDF compression.

Dependence

The only dependencies you need to install ghostscript. To do this, just go to the repo of your Linux distro or to brew if it is mac os x and install the package of the same name. For the rest the script can be put in a path to be more convenient.

Arch Linux

sudo pacman -S ghostscript

Debian Linux and derived

sudo apt install ghostscript

Fedora Linux and derived

sudo dnf install ghostscript

Mac Os X

brew install ghostscript

Of course it is also possible to install it manually.

Installation

To make the script globally accessible, you can move it to your local bin directory:

chmod +x pdfcompressor.sh
sudo mv pdfcompressor.sh /usr/local/bin/pdfcompressor

Usage

Once installed, you can use the script with the following syntax:

pdfcompressor [option] input.pdf [output.pdf]

Options

FlagLong NameDescription
-h–helpShow the help message and exit.
-f–formatSelect a specific compression level.
-fl–format-listDisplay all available compression DPI levels.
-p–prevInteractive mode with live size comparison (Preview).

Practical Examples

Basic Compression

If you don’t specify an output name, the script creates filename_comp.pdf with default settings:

pdfcompressor document.pdf

Specific Quality Level

Compress a file specifically for screen viewing (low res, small size):

pdfcompressor -f screen input.pdf output_small.pdf

Interactive Preview (Recommended)

This is the most useful feature. It allows you to test different levels and see the final file size before saving:

pdfcompressor -p my_heavy_file.pdf

Compression Levels (Ghostscript standard)

  • screen: 72 dpi (smallest size, lowest quality).
  • ebook: 150 dpi (perfect for digital reading).
  • preprint: 300 dpi (high quality, color preserving).
  • printer: 300 dpi (optimized for physical printing).
  • default: GS standard balance.