The Ultimate Guide to Installing Ghostscript

Rate this post

In this article we explore how to install Ghostscript on numerous different platforms and operating systems.

What is Ghostcript? Why install it?

What is Ghostscript, and why would we want to install it? To understand this we should first learn about Postscript.

Postscript

Postscript is a page description language geared towards desktop publishing documents.

If you want really professional-looking typesetting, layout, and graphics in your documents, desktop publishing software is what you use.

It was first created at Adobe Systems starting in 1982. As a language, it is similar to Python in that documents contain human-readable and writable commands in the language that can be parsed by an interpreter to get something done.

In the case of Python, text files containing Python commands can be parsed by the Python interpreter to create any kind of program imaginable.

In the case of Postscript, files containing Postscript commands can be parsed by a Postscript interpreter to render professional-looking documents, either to the screen or to a printer.

In addition, the PDF format is an extension of the Postscript language which adds more functionality and is now one of the most commonly used document formats.

Ghostscript

Ghostscript is a free open-source interpreter to render Postscript and PDF documents.

One of the reasons you might want to install it is to use a program that requires it.

Even without a program that needs it, installing Ghostscript can be useful:

⭐ Ghostscript can be used to modify PDF documents, such as converting PDF to images, or extracting text, among other things.

Even better, since Ghostscript provides a language-binding API, Ghostscript functions can be implemented in other languages, allowing us to write our own programs for modifying PDF documents. Supported languages are C#, Java, and Python.

Checking if Ghostscript is Already Installed

You may already have Ghostscript installed – your system may have come with it, or it may have been installed in support of a program you have installed. So save yourself some effort and check first.

Checking for Ghostscript on Windows

  1. Press Windows+R to open the β€œRun” box.   
  2. In the β€œRun” box type β€œcmd”.   
  3. A command line window opens.   
  4. In the command line window type β€œGSWIN64 -h” if your system is 64 bit (most machines these days), or β€œGSWIN32 -h” if your system is 32 bit (older machines). If Ghostscript is installed you will see Ghostscript help information. If you see an error then Ghostscript is not installed.   
  5. Type β€œexit” to close the command line window.

Checking for Ghostscript on Mac

  1. In the Finder, open the /Applications/Utilities folder, then double-click Terminal.   
  2. In the terminal window type β€œgs -h”. If Ghostscript is installed you will see Ghostscript help information. If you see an error then Ghostscript is not installed.       
  3. In the Terminal app on your Mac, choose Terminal > Quit Terminal.

Checking for Ghostscript on Linux

  1. Open a terminal window. How to do this varies depending on which distribution of Linux you are using.   
  2. In the terminal window type β€œgs -h”. If Ghostscript is installed you will see Ghostscript help information. If you see an error then Ghostscript is not installed.

Installing Ghostscript on Windows

  1. Go to the Ghostscript download page at https://www.ghostscript.com/releases/gsdnld.html    
  2. There are two license versions available: Affero GPL (AGPL), and commercial. Review the license information at https://artifex.com/licensing/. For casual use most users will chose AGPL.   
  3. Choose 64 bit or 32 bit depending on your system.   
  4. Download your choice by clicking on the chosen link.   
  5. The installer program will download.   
  6. The downloaded program will be gsxxxxw64.exe or gsxxxxw32.exe. The β€˜xxxx’ will be numbers indicating the release version. The most current version as of this writing is 9.55.0, so the installer program would be gs9550w64.exe for the 64 bit version.   
  7. Double-click the downloaded installer program.   
  8. Follow the prompts to do the installation.

Installing Ghostscript on Unix

Use this for any UNIX-based machine, so this should work for Mac or Linux.

Most UNIX systems have much easier ways of installing Ghostscript, so you will almost certainly not need to do this.

However, if you have trouble with those easier approaches you might try this as a backup.

This method usually works, but sometimes it does not, and then you need to do some troubleshooting to figure out why (the configure file might not be configured properly for your system, for example).

Also note that you will need to make sure that compiling software for Linux or Mac is installed on your system, which is beyond the scope of this article. So choose this approach as a last resort.

  1. Go to the Ghostscript download page and download the source code version. As of this writing this file is ghostscript-9.55.0.tar.gz   
  2. Move this file to some folder where you want to work.   
  3. Unarchive the downloaded file. Usually your system will be configured to do so by double-clicking the file. If not, you can unarchive using this command in the terminal: tar -xzf ghostscript-9.55.0.tar.gz. The file will unpack into sub-directories and files.   
  4. In the terminal go to the top unpacked sub-directory.   
  5. Run the configure file by typing ./configure in your terminal. This will review your system and get ready to compile the code.   
  6. Compile the code by typing make in your terminal.   
  7. Install the compiled code by typing this: sudo make install

Here are the commands for ease of copy&paste:

tar -xzf ghostscript-9.55.0.tar.gz
./configure
make
sudo make install

Installing Ghostscript on Mac

The easiest way to install Ghostscript on Mac is to use the Homebrew or Macports systems. These are package management systems for Mac that make available to the Mac the wide world of Unix open-source software.

In these systems, much of the configuring is done for you by others so that downloading and installing software is as easy as a single command, just like downloading an app for the Mac is as simple as clicking an icon in the Mac App Store.

What programs are available depends on what has been prepared by others for the system.

Fortunately, Ghostscript is available for these systems.

Setting up these systems is beyond the scope of this article. This page has a nice summary of those systems (and of the Fink system, another package management system). Follow their respective links to learn more about each system.

Install Ghostscript using Homebrew using the following command:

brew install ghostscript

Install Ghostscript using Macports using the following command:

sudo port install ghostscript

Installing Ghostscript on Ubuntu

It is often most intuitive to install software on Ubuntu using the GUI-based software application.

This accesses the repositories of extensive software available for Ubuntu.

However, it is often the fastest to do a command line install. Do so for Ghostscript as follows:

sudo apt install ghostscript

Installing Ghostscript on Other Debian-based Distributions

There are many distributions that, like Ubuntu, are based on Debian.

Many also have GUI applications for installing software, and often these can be used to install Ghostscript. But like Ubuntu, it is often the fastest to use the command line install.

The command is still the same:

sudo apt install ghostscript

Installing Ghostscript on Centos 7, and Other Red Hat/ Fedora-based Distributions

Centos 7 is a free version of the Red Hat Linux distribution, without Red Hat branding or technical support from Red Hat.

Fedora is the β€œbleeding-edge” freely available distribution in the Red Hat family of distributions that serves as the development foundation for the more robust and stable Red Hat distribution.

Since these are all in the same distribution family, they are all most quickly updated by the same command. The many other distributions in this family are also most quickly updated by the same command.

The command is:

sudo yum install ghostscript

Installing Ghostscript for Anaconda

If you are a data scientist more comfortable with data analysis in Anaconda than you are comfortable with OS management, you can still make sure you have ghostscript through Anaconda.

Open the Anaconda command line interface and enter the following command to install Ghostscript:

conda install -c conda-forge ghostscript

Installing Ghostscript in Google Colab

Ghostscript can even be installed in Google Colab.

Cells in Colab are in-effect like the Python shell. Therefore users can use the exclamation mark to submit OS shell commands, then enter the command to install Ghostscript.

The OS behind Colab operates like Ubuntu, so the installation command mirrors that of Ubuntu. Therefore, to install Ghostscript enter the following command in a Colab cell:

!apt get install ghostscript

Conclusion

Ghostscript is a free open-source interpreter that renders Postscript and PDF documents either to the screen or to a printer.

Ghostscript can also be used to process or modify such documents.

Even better, because Ghostscript includes a language-binding API, programmers can use it to write programs in other languages to modify PDF documents.

Supported languages are C#, Java, and Python.

As you can see, Ghostscript is available on many different platforms and operating systems. We have exhibited commands to install Ghostscript on many of these various platforms.

We hope you have found this helpful, and we wish you happy coding!