Monday, May 18, 2009

advanced formatting


Being able to output to paper is an important issue for any business. Just having something on paper is not all of the issue. Compare a letter that you type on a typewriter to what you print with a word processor. With a word processor, you can get different sizes or types of fonts and sometimes you can even create drawings directly in the word processor.

Many of you who have dealt with UNIX before might have the misconception that UNIX is only capable of printing simple text files. Some of you might have seen UNIX systems with a word processor that did fancy things with the output. Fortunately for us, these fancy tricks are not limited to the word processing packages. Using vi and a couple of commonly available tools, you can output in a wide range of styles.

Readily available from a number of sites, the TeX or LaTeX (pronounced Tech and Lahtech) text formatting package can be used to create professional-looking output. Many academic and research institutions running UNIX use (La)TeX as their primary text processing system. Not only is it free but the source code is also available, allowing you to extend it to suit your needs. (In many cases, the only way to get it onto your system is to get the source code and compile it.)

Like the *roff family, TeX is input directly by the writer. These source files are then run through a processor that formats the output based on codes that were input. This process generates a device independent file, usually with the extension .dvi. The .dvi files are analogous to .o files in C because they need to be manipulated further to be useful. Unfortunately, this does not work for every kind of printer.

If your printer does not understand the .dvi file, the dvips program will convert the .dvi file to PostScript. If your printer doesn't support PostScript, you can use ghostview to output to a format your printer can understand.

Included on your system (provided you installed the TeX package) is the dvips program, which converts the .dvi files to PostScript. These PostScript files can be printed out on any compatible printer.

At first this may sound a little confusing and annoying. You have to use so many tools that just to get a simple printout. First, if all you really need is a simple printout, you probably won't need to go through all of these steps. This demonstrates that no matter what standard you choose to use, there are Linux tools available to help you get your job done.

Many different programs are available to allow you to print out, view, and manipulate PostScript files. Ghostscript is a program used to view PostScript files. These need not be files that you generated on your local machine, but any PostScript files you have. Ghostscript can also be used to print PostScript files to print the file to non-PostScript-compatible printers.

Ghostscript supports the resolutions that most printers can handle. However, if you are printing to a dot-matrix printer, you need to be especially careful about getting the right resolution because it is not normally the standard 300 DPI.

I have to pause here to remind you about working with PostScript files and printers. Sometimes the printer is PostScript-compatible, but you have to tell it to process the file as PostScript and not as raw text. This applies to older models of certain laser jet printers. Once, I wanted to print out a 50-page document and forgot to set the flag to say that it was a PostScript file. The result was that instead of 50 pages, I ended up with more than 500 pages of PostScript source.

Under Linux, printers are not the only way you can get words on paper. As of this writing, there are at least three packages with which you can fax documents from your Linux system. First, however, you must have a fax modem with which you can connect.

Here I need to side-step for a minute. The older type of fax, Class 1 faxes, did not have as much processing power distributed in the hardware. Instead, the software took over this job. It works fine on single-user systems like Windows, but under pre-emptive multitasking systems like Linux, you can run into timing problems. (Pre-emptive multitasking is where the operating system decides which process will run and therefore could pause the fax program at a crucial moment. More details can be found in the section on processes.)

In addition to Class 1, faxes fall into different groups. To work correctly, the fax software needs to convert the document you are sending into a group-III-compatible image. This can be done with Ghostscript.

The GNU netfax program accepts several different file formats (as of this writing, PostScript, dvi, and ASCII). Originally available from prep.ai.mit.edu, it is no longer supported by the GNU. More extensive than netfax is HylaFlex (renamed from FlexFax available to avoid trademark conflicts). This is available (as of this writing) with ftp from sgi.com under /sgi/fax/. With this package, not only can you send faxes, but you can configure it to receive them as well.

Man-pages are something that you may need to print. If you have files in ASCII format (the cat pages), this is not an issue. However, with pages that have been formatted with *roff formatting, you have a couple of choices. The man program has the ability to process files with *roff formatting. By redirecting the output on man to a file (often piping it through col), you can get clean ASCII text that you can then print.

No comments:

Post a Comment