Before an ASCII file can be printed through Ghostscript, it needs to be converted into PostScript, because this is the input format that Ghostscript expects. This conversion can be achieved with a2ps (a2ps package). As a2ps is not installed by default, you will normally have to install it yourself. The a2ps program is a powerful, versatile tool that lets you convert simple text files into high-quality PostScript output. It has a large number of command-line options. Learn about these in the manual page of a2ps or read the full documentation of a2ps as an info page.
As a first example, a2ps can be used to convert a text file into PostScript, with two pages scaled down so they fit on one sheet. This can be achieved with the command:
a2ps -2 --medium=A4dj --output=/tmp/out.ps textfile
The output of a2ps can then be displayed under X with
gs -r60 /tmp/out.ps
to get a preview of the printout. If the printout is more than one sheet, hit Enter in the terminal window from which gs was started to scroll down to the next page. To exit gs, enter Ctrl-C.
Take the output of a2ps and convert it into your printer's language by entering:
gs -q -dNOPAUSE -dSAFER -sOutputFile=/tmp/out.prn \ <driverparameter> /tmp/out.ps quit.ps
In the above command, specify your own driver parameters under driverparameters as described in the previous section.
As root, you can send the output of Ghostscript directly to the printer without relying on a spooler or any further filtering with the command
cat /tmp/out.prn >/dev/lp0
It is assumed here that the printer is connected to the first parallel port (/dev/lp0).