LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

ghostscript

Interpreter for PostScript and PDF file manipulation

TLDR

Convert PDF to images
$ gs -dNOPAUSE -dBATCH -sDEVICE=png16m -r300 -sOutputFile=[page-%d.png] [input.pdf]
copy
Merge PDFs
$ gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=[merged.pdf] [file1.pdf] [file2.pdf]
copy
Compress PDF
$ gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -sOutputFile=[small.pdf] [large.pdf]
copy
Convert PS to PDF
$ gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=[output.pdf] [input.ps]
copy
Extract pages from PDF
$ gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dFirstPage=[2] -dLastPage=[5] -sOutputFile=[extract.pdf] [input.pdf]
copy

SYNOPSIS

gs [options] [files]

DESCRIPTION

Ghostscript (gs) is an interpreter for PostScript and PDF. It renders documents to various output formats, converts between formats, and processes print jobs. It is the engine behind many PDF tools and print systems on Unix/Linux.The tool supports a wide range of output devices for rasterization, format conversion, and print processing. PDF manipulation includes merging, splitting, compressing, and converting between quality levels.

PARAMETERS

-dNOPAUSE

Don't pause between pages.
-dBATCH
Exit after processing.
-sDEVICE device
Output device (pdfwrite, png16m, jpeg, etc.).
-sOutputFile file
Output filename (use %d for page numbers).
-r resolution
Resolution in DPI.
-dPDFSETTINGS setting
PDF quality: /screen, /ebook, /printer, /prepress.
-dFirstPage n
Start page.
-dLastPage n
End page.
-dCompatibilityLevel ver
PDF version (1.4, 1.5, etc.).
-q
Quiet mode; suppress startup messages.
-dSAFER
Restrict file operations for safety (default in recent versions).

CONFIGURATION

/etc/ghostscript/

System-wide configuration directory for font mappings, resource files, and initialization scripts.
~/.ghostscript
User-specific Ghostscript resources and configuration overrides.

INSTALL

sudo apt install ghostscript
copy
sudo dnf install ghostscript
copy
sudo pacman -S ghostscript
copy
sudo zypper install ghostscript
copy
brew install ghostscript
copy
nix profile install nixpkgs#ghostscript
copy

CAVEATS

Complex command-line syntax. Some operations require specific device drivers. Font handling may need configuration. Security settings restrict file operations.

HISTORY

Ghostscript was started by L. Peter Deutsch in 1988 as a free PostScript interpreter. It's now developed by Artifex Software and remains fundamental to Unix/Linux printing and PDF processing.

SEE ALSO

pdf2ps(1), ps2pdf(1), pdftk(1), convert(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid