![]() | ![]() |
|
The Linux Printing Usage HOWTOby Mark Komarinski <markk@auratek.com>v1.2.2, 6 February 1998
1. Introduction
2. Printing Under Linux
3. Printing files
4. Miscellaneous Items
5. Answers to Frequently Asked Questions
6. Troubleshooting
7. References1. IntroductionThis document describes how to use the line printer spooling system provided with the Linux operating system. This HOWTO is the supplementary document to the Linux Printing Setup HOWTO, which discusses the installation and setup of the Linux printing system. The material presented in this HOWTO should be equally relevent for all flavors of the BSD operating system in addition to the Linux operating system.
1.1 Linux Printing HOWTO HistoryNote from Mark Komarinski <markk@auratek.com>: I'd like to thank Matt Foster for doing a lot of work in the re-write of this HOWTO. I'm keeping his style, and adding when necessary to keep everything updated. Note from Matt Foster <mwf@engr.uark.edu>: This version of the Linux Printing HOWTO is a complete rewrite of the one originally written by Grant Taylor <grant@god.tufts.edu> and Brian McCauley <B.A.McCauley@bham.ac.uk>. I have tried to keep with the coverage of material presented by Grant and Brian's HOWTO, but I have drastically modified the style of presentation and the depth of material covered. I feel that this makes the HOWTO more complete and easier to read. I can only hope that you agree.
1.2 Version Historyv1.2.2
v1.1
v1.0
1.3 Copyrights and TrademarksSome names mentioned in this HOWTO are claimed as copyrights and/or trademarks of certain persons and/or companies. These names appear in full or initial caps in this HOWTO. (c) 1995 Matt Foster (mwf@engr.uark.edu) All translations, derivative works, or aggregate works incorporating any Linux HOWTO documents must be covered under this copyright notice. That is, you may not produce a derivative work from a HOWTO and impose additional restrictions on its distribution. Exceptions to these rules may be granted under certain conditions; please contact the Linux HOWTO coordinator at the address given below. In short, we wish to promote dissemination of this information through as many channels as possible. However, we do wish to retain copyright on the HOWTO documents, and would like to be notified of any plans to redistribute the HOWTOs.
If you have questions, please contact Tim Bynum, the Linux HOWTO coordinator, at <linux-howto@sunsite.unc.edu>. You may finger this address for phone number and additional contact information.
1.4 Downloading the Linux Printing HOWTOsI recommend that if you want to print a copy of this HOWTO that you download the PostScript version. It is formatted in a fashion that is aesthetically appealing and easier to read. You can get the PostScript version from one of the many Linux distribution sites (such as SunSITE ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO/).
1.5 FeedbackQuestions, comments, or corrections for this HOWTO may be directed to <markk@auratek.com>.
1.6 AcknowledgmentsThanks go out to all of the people who took the time to read the alpha version of this HOWTO and respond with many helpful comments and suggestions---some of you may see your comments reflected in the version. I'd also like to thank Matt Foster who did the original re-write.
2. Printing Under LinuxThis section discusses how to print files, examine the print queue, remove jobs from the print queue, format files before printing them, and configure your printing environment.
2.1 History of Linux PrintingThe Linux printing system---the lp system---is a port of the source code written by the Regents of the University of California for the Berkeley Software Distribution version of the UNIX operating system.
2.2 Printing a File Using lpr
By far, the most simplistic way to print in the Linux operating system is
to send the file to be printed directly to the printing device. One way
to do this is to use the cat command. As the
In this case, For the purpose of security, only the Because of this, users have to use lpr to print a file. The lpr command takes care of all the initial work needed to print the file, and then it hands control over to another program, lpd, the line printing daemon. The line printing daemon then tells the printer how to print the file. When lpr is executed, it first copies the specified file to a certain directory (the spool directory) where the file remains until lpd prints it. Once lpd is told that there is a file to print, it will spawn a copy of itself (what we programmers call forking). This copy will print our file while the original copy waits for more requests. This allows for multiple jobs to be queued at once. The syntax of lpr(1) is a very familiar one,
If
or,
The lpr command accepts several command-line arguments that allow a user to control how it works. Some of the most widely used arguments are: -Pprinter specifies the printer to use, -h suppresses printing of the burst page, -s creates a symbolic link instead of copying the file to the spool directory (useful for large files), and -#num specifies the number of copies to print. An example interaction with lpr might be something like
This command will create a symbolic link to the file For a listing of all the options that lpr will recognize, see lpr(1).
2.3 Viewing the Print Queue with lpqTo view the contents of the print queue, use the lpq command. Issued without arguments, it returns the contents of the default printer's queue. The returned output of lpq can be useful for many purposes.
2.4 Canceling a Print Job Using lprmAnother useful feature of any printing system is the ability to cancel a job that has been previously queued. To do this, use lprm.
The above command cancels all of the print jobs that are owned by the user who issued the command. A single print job can be canceled by first getting the job number as reported by lpq and then giving that number to lprm. For example,
would cancel job 31 (
2.5 Controlling the lpd program with lpcThe lpc(8) program is used to control the printers that lpd serves. you can enable or disable a printer or its queues, rearrange entries within a queue, and get a status report on the printers and their queues. Lpc is mostly used in a setup where there are multiple printers hanging off one machine.
The above will start the lpc program. By default, this enters you into an interactive mode, and you can begin issuing commands. The other option is to issue an lpc command on the command line.
A list of the available commands are in the lpd man page, but here
are a few of the major commands you'll want to know about. Any commands
marked with option can either be a printer name (lp, print, etc) or
the keyword
2.6 The RedHat printtoolJust a quick note here on RedHat's amazing printtool program. It seems to do everything that a magicfilter would do. RedHat already installs many of the programs to do the filtering. Here's how I have my printer set up under RH 4.0 with an HP LJ 4L connected to my parallel port (should be the same for other versions of RH as well).
3. Printing filesThis section covers printing the kinda of files that you'll run across in a Linux setup.
3.1 Printing graphics filesPrinting graphics files through a printer usually depends on the kind of graphics you're converting, and the kind of printer you want to send to. Dot matrix is usually out of the question due to differences in the way dot-matrix handles graphics. Your best bet in this situation is to see if your printer is compatable with an Epson or an IBM ProPrinter, then convert the graphics file to PostScript, then use Ghostscript (see next section) to print the graphics. If you have a laser printer, things are a bit easier since many are compatable with PCL. This now gives you a few options. Some programs may output directly in PCL. If not, programs like NetPBM can convert into PCL. Last option is to use ghostscript (see next section). Your absolutely best option is to install packages like NetPBM and Ghostscript then installing a magic filter to process the graphics files automagically.
3.2 Printing PostScript filesPrinting PostScript files on a printer that has a PostScript interpreter is simple; just use lpr, and the printer will take care of all of the details for you. For those of us that don't have printers with PostScript capabilities, we have to resort to other means. Luckily, there are programs available that can make sense of PostScript, and translate it into a language that most printers will understand. Probably the most well known of these programs is Ghostscript. Ghostscript's responsibility is to convert all of the descriptions in a PostScript file to commands that the printer will understand. To print a PostScript file using Ghostscript, you might do something like
Notice in the above example that we are actually piping the output of Ghostscript to the lpr command by using the -sOutputFile option. Ghostview is an interface to Ghostscript for the X Window System. It allows you to preview a PostScript file before you print it. Ghostview and Ghostscript can both be swiped from ftp://prep.ai.mit.edu/pub/gnu/.
3.3 Printing PDF filesAdobe has released an Acrobat reader for Linux, and it's available on the Adobe home page http://www.adobe.com. Its predecessor, xpdf, is also available. Both should print to a postscript device.
3.4 Printing TeX filesOne of the easiest ways to print TeX files is to convert them to PostScript and then print them using Ghostscript. To do this, you first need to convert them from TeX to a format known as DVI (which stands for device-independent). You can do this with the tex(1) command. Then you need to convert the DVI file to a PostScript file using dvips. All of this would look like the following when typed in.
Now you are ready to print the resulting PostScript file as described above.
3.5 Printing
|
![]() |