8.1. Printing files

8.1.1. General

RedHat ships with LPRng, an improved version of the well-known UNIX print system. If the printer has been set up, all you need to do is learn how to use lpr to send files to the printer, which basically comes down to

lpr file(s)

Lpr uses a spooling daemon, lpd to print the named files when facilities become available. If no names appear, standard input is assumed (such as when the output of a command is piped into lpr). The lpr command has a lot of options, which can be displayed using the --help option. Full information is in the Info pages. You will also find the lp command on your Linux system, for compatibility reasons with other (UNIX) programs. You will find that lp is in fact a symbolic link to lpr:

davy:~>ls -l /usr/bin/lp*
lrwxrwxrwx  1 root    root        3 Oct 28 14:21 /usr/bin/lp -> lpr
-rwxr-xr-x  1 lp      lp     395192 Aug 11  2001 /usr/bin/lpq
-rwxr-xr-x  1 lp      lp     408536 Aug 11  2001 /usr/bin/lpr
-rwxr-xr-x  1 lp      lp     392984 Aug 11  2001 /usr/bin/lprm
-rwxr-xr-x  1 root    root     4651 Oct 19 22:17 /usr/bin/lprsetup.sh
-rwxr-xr-x  1 lp      lp     398488 Aug 11  2001 /usr/bin/lpstat
davy:~>ps -ef | grep lpd
lp        1003     1  0 Feb22 ?        00:00:00 lpd Waiting

Once the file is accepted in the print queue, an identification number for the print job is assigned:

davy:~>lp /etc/profile
request id is davy@blob+253

To view (query) the print queue, use the lpq command. When entered without arguments, it displays the contents of the default print queue.

Printer: lp@blob
 Queue: no printable jobs in queue
 Status: job 'cfA284blob.somewhere.org' removed at 11:02:47.098

If you don't like what you see, use lprm to delete jobs. Use lprm - to delete all jobs which you submitted. If you only want to cancel one job, use the number of that job as an argument to lprm.

In larger environments, lpc may be used to control multiple printers. See the Info on each command.

There are many GUI print tools used as a front-end to lpr, and most graphical applications have a print function that uses lpr. See the built-in Help functions and program specific documentation for more.

8.1.2. Formatting Tools

If we want to get something sensible out of the printer, files should be formatted first. Apart from an abundance of formatting software, Linux comes with the basic UNIX formatting tools and languages.

Most markup languages are more suitable for large or repetitive jobs, where the computer controls the layout of the text, like when executing scripts.

  • groff: GNU version of the UNIX roff command. It is a front-end to the groff document formatting system. Normally it runs the troff command and a post-processor appropriate for the selected device. It allows generation of PostScript files.

  • TeX and the macro package LaTeX: one of the most widely used markup languages on UNIX systems. Usually invoked as tex, it formats files and outputs a corresponding device-independent representation of the typeset document.

    Technical works are still frequently written in LaTeX because of its support for mathematic formulas, although efforts are being made at W3C (the World Wide Web Consortium) to include this feature in other applications.

  • SGML and XML: Free parsers are available for UNIX and Linux. XML is the next generation SGML, it forms the basis for DocBook XML, a document system (this book is written in XML, for instance).

Linux comes with a lot of formatting tools, such as pdf2ps, fax2ps and a2ps.

Apart from these command line tools there are a lot of graphical word processing programs. Several complete office suites are available, many are free. These do the formatting automatically upon submission of a print job. Just to name a few: AbiWord, KWord, StarOffice, OpenOffice, Applix, WordPerfect, etc.

NotePrinting documentation

The man pages contain pre-formatted troff data, they have to be formatted as well. Printing is done using the -t option:

man -t command > man-command.ps

Then print the PostScript file. For printing Info pages, refer to the Info pages on info (you will need the source code of the command). Previewing formatted files

Anything you can send to the printer, can normally be sent to the screen as well. Depending on the file format, you can use one of these commands:

  • PostScript files: with the gv (GhostView) command.

  • TeX dvi files: with xdvi.

  • PDF files: xpdf or Adobe's viewer, acroread, which is also available for free.