Sick Gaming
[Tut] The Ultimate Guide to Installing Ghostscript - Printable Version

+- Sick Gaming (https://www.sickgaming.net)
+-- Forum: Programming (https://www.sickgaming.net/forum-76.html)
+--- Forum: Python (https://www.sickgaming.net/forum-83.html)
+--- Thread: [Tut] The Ultimate Guide to Installing Ghostscript (/thread-99177.html)



[Tut] The Ultimate Guide to Installing Ghostscript - xSicKxBot - 04-10-2022

The Ultimate Guide to Installing Ghostscript

<div><p>In this article we explore how to install Ghostscript on numerous different platforms and operating systems.</p>
<h2>What is Ghostcript? Why install it?</h2>
<p>What is Ghostscript, and why would we want to install it? To understand this we should first learn about Postscript.</p>
<h3>Postscript</h3>
<p>Postscript is a page description language geared towards desktop publishing documents.</p>
<p><em>If you want really professional-looking typesetting, layout, and graphics in your documents, desktop publishing software is what you use. </em></p>
<p>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. </p>
<p>In the case of Python, text files containing Python commands can be parsed by the Python interpreter to create any kind of program imaginable. </p>
<p>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. </p>
<p>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.</p>
<h3>Ghostscript</h3>
<p>Ghostscript is a free open-source interpreter to render Postscript and PDF documents. </p>
<p>One of the reasons you might want to install it is to use a program that requires it. </p>
<p>Even without a program that needs it, installing Ghostscript can be useful: </p>
<p class="has-global-color-8-background-color has-background"><img src="https://s.w.org/images/core/emoji/13.1.0/72x72/2b50.png" alt="⭐" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Ghostscript can be used to modify PDF documents, such as converting PDF to images, or extracting text, among other things. </p>
<p>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.</p>
<h2>Checking if Ghostscript is Already Installed</h2>
<p>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.</p>
<h3>Checking for Ghostscript on Windows</h3>
<ol>
<li>Press <code>Windows+R</code> to open the “<code>Run</code>” box.   </li>
<li>In the “<code>Run</code>” box type “<code>cmd</code>”.   </li>
<li>A command line window opens.   </li>
<li>In the command line window type “<code>GSWIN64 -h</code>” if your system is 64 bit (most machines these days), or “<code>GSWIN32 -h</code>” 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.   </li>
<li>Type “<code>exit</code>” to close the command line window.</li>
</ol>
<h3>Checking for Ghostscript on Mac</h3>
<ol>
<li>In the Finder, open the <code>/Applications/Utilities</code> folder, then double-click <code>Terminal</code>.   </li>
<li>In the terminal window type “<code>gs -h</code>”. If Ghostscript is installed you will see Ghostscript help information. If you see an error then Ghostscript is not installed.       </li>
<li>In the <code>Terminal</code> app on your Mac, choose <code>Terminal > Quit Terminal</code>.</li>
</ol>
<h3>Checking for Ghostscript on Linux</h3>
<ol>
<li>Open a terminal window. How to do this varies depending on which distribution of Linux you are using.   </li>
<li>In the terminal window type “<code>gs -h</code>”. If Ghostscript is installed you will see Ghostscript help information. If you see an error then Ghostscript is not installed.</li>
</ol>
<h2>Installing Ghostscript on Windows</h2>
<ol>
<li>Go to the Ghostscript download page at <a rel="noreferrer noopener" href="https://www.ghostscript.com/releases/gsdnld.html" target="_blank">https://www.ghostscript.com/releases/gsdnld.html</a>    </li>
<li>There are two license versions available: Affero GPL (AGPL), and commercial. Review the license information at <a rel="noreferrer noopener" href="https://artifex.com/licensing/" target="_blank">https://artifex.com/licensing/</a>. For casual use most users will chose AGPL.   </li>
<li>Choose 64 bit or 32 bit depending on your system.   </li>
<li>Download your choice by clicking on the chosen link.   </li>
<li>The installer program will download.   </li>
<li>The downloaded program will be <code>gsxxxxw64.exe</code> or <code>gsxxxxw32.exe</code>. The ‘<code>xxxx</code>’ will be numbers indicating the release version. The most current version as of this writing is <code>9.55.0</code>, so the installer program would be <code>gs9550w64.exe</code> for the 64 bit version.   </li>
<li>Double-click the downloaded installer program.   </li>
<li>Follow the prompts to do the installation.</li>
</ol>
<h2>Installing Ghostscript on Unix</h2>
<p>Use this for any UNIX-based machine, so this should work for Mac or Linux.</p>
<p>Most UNIX systems have much easier ways of installing Ghostscript, so you will almost certainly not need to do this. </p>
<p>However, if you have trouble with those easier approaches you might try this as a backup. </p>
<p>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). </p>
<p>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.</p>
</p>
<ol>
<li>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   </li>
<li>Move this file to some folder where you want to work.   </li>
<li>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: <code>tar -xzf ghostscript-9.55.0.tar.gz</code>. The file will unpack into sub-directories and files.   </li>
<li>In the terminal go to the top unpacked sub-directory.   </li>
<li>Run the configure file by typing <code>./configure</code> in your terminal. This will review your system and get ready to compile the code.   </li>
<li>Compile the code by typing <code>make</code> in your terminal.   </li>
<li>Install the compiled code by typing this: <code>sudo make install</code></li>
</ol>
<p>Here are the commands for ease of copy&amp;paste:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">tar -xzf ghostscript-9.55.0.tar.gz
./configure
make
sudo make install</pre>
<h2>Installing Ghostscript on Mac</h2>
<p>The easiest way to install Ghostscript on Mac is to use the <strong>Homebrew</strong> or <strong>Macports</strong> systems. These are package management systems for Mac that make available to the Mac the wide world of Unix open-source software. </p>
<p>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. </p>
<p>What programs are available depends on what has been prepared by others for the system. </p>
<p>Fortunately, Ghostscript is available for these systems. </p>
<p>Setting up these systems is beyond the scope of this article. This<a href="https://www.scivision.dev/homebrew-macports-fink/" target="_blank" rel="noreferrer noopener"> page</a> 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.</p>
<p>Install Ghostscript using Homebrew using the following command:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">brew install ghostscript</pre>
<p>Install Ghostscript using Macports using the following command:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">sudo port install ghostscript</pre>
<h2>Installing Ghostscript on Ubuntu</h2>
<p>It is often most intuitive to install software on Ubuntu using the GUI-based software application. </p>
<p>This accesses the repositories of extensive software available for Ubuntu. </p>
<p>However, it is often the fastest to do a command line install. Do so for Ghostscript as follows:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">sudo apt install ghostscript</pre>
<h2>Installing Ghostscript on Other Debian-based Distributions</h2>
<p>There are many distributions that, like Ubuntu, are based on Debian. </p>
<p>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. </p>
<p>The command is still the same:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">sudo apt install ghostscript</pre>
<h2>Installing Ghostscript on Centos 7, and Other Red Hat/ Fedora-based Distributions</h2>
<p>Centos 7 is a free version of the Red Hat Linux distribution, without Red Hat branding or technical support from Red Hat. </p>
<p>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. </p>
<p>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. </p>
<p>The command is:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">sudo yum install ghostscript</pre>
<h2>Installing Ghostscript for Anaconda</h2>
<p>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. </p>
<p>Open the Anaconda command line interface and enter the following command to install Ghostscript:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">conda install -c conda-forge ghostscript</pre>
<h2>Installing Ghostscript in Google Colab</h2>
<p>Ghostscript can even be installed in Google Colab. </p>
<p>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. </p>
<p>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:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">!apt get install ghostscript</pre>
<h2>Conclusion</h2>
<p>Ghostscript is a free open-source interpreter that renders Postscript and PDF documents either to the screen or to a printer. </p>
<p>Ghostscript can also be used to process or modify such documents. </p>
<p>Even better, because Ghostscript includes a language-binding API, programmers can use it to write programs in other languages to modify PDF documents. </p>
<p>Supported languages are <a href="https://blog.finxter.com/c-developer-income-and-opportunity/" data-type="post" data-id="189360" target="_blank" rel="noreferrer noopener">C#</a>, <a href="https://blog.finxter.com/java-developer-income-and-opportunity/" data-type="post" data-id="217907" target="_blank" rel="noreferrer noopener">Java</a>, and <a href="https://blog.finxter.com/python-developer-income-and-opportunity/" data-type="post" data-id="189354" target="_blank" rel="noreferrer noopener">Python</a>.</p>
<p>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. </p>
<p>We hope you have found this helpful, and we wish you happy coding!</p>
<hr class="wp-block-separator"/>
</div>


https://www.sickgaming.net/blog/2022/04/02/the-ultimate-guide-to-installing-ghostscript/