GNU Ghostscript
Viewing an Encapsulated PostScript recycling logo in a TeX document should have been simple enough. Instead, a blank space marked the position on the display where the logo should have appeared. A quick look through all of my LaTeX documentation, including the xdvi man page, provided no answer. There seemed to be no way for xdvi to display a TeX \special command in the dvi output; in this case, an embedded PostScript image. I considered this to be a major shortcoming of xdvi, and, of course, TeX. After all, isn't combining text and graphics on a page part of what computer publishing is all about? Why should TeX, one of the most sophisticated typesetting systems in the world, be constrained by the lack of a PostScript previewer? Or the requirement for a PostScript printer, for that matter? It is said that the longest journey begins with a single step. The journey I'm about to describe has brought me a considerable distance toward professional-quality publishing, via a utility that had been sitting quietly in a subdirectory of my /usr partition all along.
The utility is Ghostscript. GNU Ghostscript, Version 3.33, is the Swiss Army knife of graphics programs. Essentially, it's a PostScript language interpreter. More specifically, Ghostscript renders PostScript code to any bitmapped device on your system, whether it be the screen, printer, or G3 fax file. The man page says, “Ghostscript is a programming language similar to Adobe System's PostScript language, which is in turn similar to Forth.” (This statement comes almost verbatim from the book: Adobe Systems, Incorporated: PostScript: Language Tutorial and Cookbook, Addison-Wesley, 1986.) Ghostscript also substitutes fonts from its own library when rendering documents if the fonts are not otherwise available, scales and rotates text, and performs any of the other typographical feats for which PostScript is famous. Despite the apparent complexity of the task, no knowledge of the PostScript language is required. For the most part, a little experimentation with the command-line options is all that's needed. Yet Ghostscript's PostScript interpreter is fully accessible.
If I want to print that EPS recycling logo at the bottom of a page of DVI output, I would insert the following commands in my LaTeX input file:
\usepackage{graphics} ... \vfil \includegraphics{recycle.eps}
Then, it is simply a matter of running the input file through teTeX, using the command line:
pslatex letter.texand then converting teTeX's dvi output to PostScript with dvips:
dvips -f <letter.dvi >letter.psThe -f command-line option tells dvips to act as a filter, reading from standard input and writing to standard output. Now, we have a PostScript file ready for printing. Ghostscript images this file in a format that's understandable to any bitmapped device on your system, whether it is a VGA display or a laser printer.
Ghostscript's command-line options are numerous. Look at ghostscript's USE.DOC file for an complete description. You can view a brief summary with the command:
gs -help | less
For example, if I want to print the file letter.ps on a Hewlett Packard DeskJet printer, I would use the command line:
gs -q -dNOPAUSE -sDEVICE=deskjet
/-sOutputFile=-\
letter.ps quit.ps >gs.out
The first option, -q, suppresses messages to the
console. However, to run Ghostscript in batch mode, the
-q option on its own is not enough. That's
because Ghostscript uses its own PostScript code at run time to
output the image.
From the command line, we define several variables, the first being NOPAUSE, which tells Ghostscript's showpage() routine not to pause after each page is output. When viewing output on a screen, it is best to leave NOPAUSE unset and let Ghostscript prompt you to view each page in turn.
Next, we set the DEVICE variable. In the example above, the output device is a HP Deskjet. Ghostscript's dictionary has output parameters defined for all the devices documented in its command-line help.
The next variable which needs defining is OutputFile. Here, we set it to - or standard output. This is the file to which Ghostscript will write its image. In most instances, however, Ghostscript provides no means for that image to be displayed. We'll get to that in a moment. Then we specify letter.ps on the command line as our target input file.
When we write a file with the pslatex command, LaTeX uses the font metrics available to it; that is, it uses Computer Modern Roman as its default font. However, the pslatex command has been implemented in teTeX so that dvips, which does the DVI to PostScript conversion, will request PostScript fonts. These fonts can be provided via either the printer or via software. In the latter case, Ghostscript produces the output image using Type 1 fonts from its own library.
Finally, we input the file quit.ps. This file is part of Ghostscript's standard library and is simply the command quit followed by a newline character. It is read into the Ghostscript interpreter just like any other input.
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
- RSS Feeds
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- New Products
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- Validate an E-Mail Address with PHP, the Right Way
- Tech Tip: Really Simple HTTP Server with Python
- Trying to Tame the Tablet
- New Products
- Ahh, the Koolaid.
6 min 18 sec ago - git-annex assistant
6 hours 5 min ago - direct cable connection
6 hours 28 min ago - Agreed on AirDroid. With my
6 hours 38 min ago - I just learned this
6 hours 42 min ago - enterprise
7 hours 12 min ago - not living upto the mobile revolution
10 hours 4 min ago - Deceptive Advertising and
10 hours 39 min ago - Let\'s declare that you have
10 hours 40 min ago - Alterations in Contest Due
10 hours 41 min ago
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.




Comments
Emacs Tex mode printing via Ghostscript shell scripts
The section "Ghostscript as a Document Post-Processor and Previewer" of this article sounds very interesting but doesn't work. More explanation would be nice.
Alex.
Re: Emacs TeX mode printing via Ghostscript shell scripts
Try to isolate the problem. Do the individual utilities run correctly from the shell prompt? Then, do the shell scripts run correctly from the shell? If they don't, then try to include the error messages. If they do, then try to include the debug output from the Emacs interpreter. Also include the version of each utility, so I can duplicate the errors produced by newer versions. Or, you can follow these procedures, and submit a patch.
Robert Kiesling