Chapter 15 Using the Printer

The concept of device independence may have seemed all well and good in the past four chapters, when we were using the video display for text and graphics, but how well does the concept hold up for printers and plotters? In general, the news is good. Under Windows, printers and plotters have a device-independent graphics interface. You can forget about printer control sequences and communications protocols when programming for the printer. Retail Windows programs conspicuously lack the disks of specialized printer drivers that have characterized recent word-processing software and graphics programs for MS-DOS. When a retail Windows program includes printer drivers, they are usually enhanced versions of existing printer drivers.

From a Windows program, you can print text and graphics on paper using the same GDI functions that we've been using for the video display. Many of the issues of device independence that we've explored in the past four chapters—mostly related to the size and resolution of the display surface and its color capabilities—can be approached and resolved in the same way. Yet a printer or plotter is not simply a display that uses paper rather than a cathode-ray tube. There are some very significant differences. For example, we have never had to consider the problem of a video display not being connected to the display adapter or of the display ”running out of screen,“ but it is common for a printer to be off line or to run out of paper.

Nor have we worried about the video display adapter being incapable of performing certain graphics operations. Either the display adapter can handle graphics or it can't. And if it can't, then it can't be used with Windows at all. But some printers can't print graphics (although they can still be used with Windows), and plotters can do vector graphics but have a real problem with bit-block transfers.

Here are some other issues to consider:

Printers are slower than video displays. Although we have on occasion tried to tune our programs for best performance, we haven't worried about the time required for the video display to be refreshed. But nobody wants to wait for a printer to finish printing before getting back to work.

Programs reuse the surface of the video display as they overwrite previous display output with new output. This can't be done on a printer. Instead, a printer must eject a completed page and go on to the next page.

On the video display, different applications are windowed. On a printer, output from different applications must be separated into distinct documents or print jobs.

To add printer support to the rest of GDI, Windows includes only one new function, called Escape. Well, it's actually more than one. Escape has many subfunctions that are indicated by one of the Escape parameters. For example, the three most common Escape subfunctions are STARTDOC and ENDDOC (which begin and end a printing job) and NEWFRAME (which ends one page and goes on to the next).