The Spool Library: 7.2 Other Printing Components: Printer Drivers

Up: GEOS SDK TechDocs | Up | Prev: 7.1 Spooler and Scheduling | Next: 7.3 Page Size Related Routines

Printer Drivers are very important but at the same time not something that any geode you write is going to interact with. Printer Drivers take care of translating the device-independent graphics commands into forms that individual models of printers can work with. Drivers also provide the Spooler with information about the printer and provide printer-specific UI to the Print Control.

As long as a geode uses only device-independent graphics commands, that geode need not worry about printer drivers. In fact, the only geodes that require knowledge of printer drivers are those that use Raw Mode (see below) printing and access the printer drivers directly. To incorporate Raw Mode printing into a geode (normally a bad idea), keep reading. Whether or not the geode you're writing will interact with Printer Drivers, you might want to continue reading this section to find out what printer drivers do.

Dumb Printers

When dealing with a printer that has no page description language, the Spooler and Printer Driver have to be clever. First the Spooler allocates an offscreen bitmap and plays back the contents of the spool file into the bitmap. It does this through the vidmem driver, which has the same interface as a video driver but draws to offscreen bitmaps instead of to a device. Once the bitmap is complete, the Spooler starts feeding the bitmap to the Printer Driver, which translates the bitmap into a series of commands to the printer. If (as is often the case) the printer doesn't have enough memory to absorb a whole page's worth of data at a time, the Printer Driver feeds in one horizontal band, or "swath" of the bitmap at a time. This also allows for better backgrounding: The driver can feed in a swath, then block and allow other threads to complete other tasks until the printer is ready for the next swath.

Smart Printers

When dealing with an "intelligent" printer, a printer that has its own page description language, the Spooler bypasses most of the work it has to do when dealing with dumb printers. Since an intelligent printer presumably has some commands with GEOS equivalents, the Spooler doesn't bother with creating a bitmap but just passes the GString on to the Printer Driver. The Printer Driver then builds a page description in the printer's native language based on the contents of the GString.

Raw Mode

If you want to use some printer-specific command that doesn't have an equivalent in the GEOS graphics system, you will use raw mode. Raw Mode printing expects that you know what sorts of commands the printer will be expecting. If you try to send PostScript commands to a printer that doesn't understand PostScript, probably the results won't be the desired output.

Printer Information and Manipulation

SpoolGetNumPrinters(), SpoolGetPrinterString(), SpoolGetPrinterInfo(), SpoolCreatePrinter(), SpoolDeletePrinter(), SpoolGetDefaultPrinter(), SpoolSetDefaultPrinter()

If you want to find out something about a printer without accessing the printer driver directly, the spool library provides a number of utility routines that work with printer drivers.

Most of these functions specify which of a user's printers they wish to work with by passing its printer number. The first installed printer will be printer number zero, the second printer will be number one, and so on. Use the SpoolGetNumPrinters() routine to find out how many printers have been installed. Once you have this number, you have an upper bound for printer numbers to test. There will always be fewer than MAXIMUM_NUMBER_OF_PRINTERS printers.

The SpoolGetPrinterString() and SpoolGetPrinterInfo() routines return information about the printer associated with the passed printer number. SpoolGetPrinterString() returns the a string containing the name of the printer, such as "HP DeskJet on COM1." The printer string will be of length at most MAXIMUM_PRINTER_NAME_LENGTH. SpoolGetPrinterInfo() returns various pieces of information helpful to geodes that work with printers directly.

The SpoolCreatePrinter() and SpoolDeletePrinter() routines can install and uninstall printers, tasks probably best left to the Preferences Manager. The SpoolDeletePrinter() routine uninstalls the printer corresponding to the passed printer number. It is easy to use but not something that most geodes should be doing. SpoolCreatePrinter() installs a new printer, returning the new printer's printer number. Note that any geode calling this latter function is going to be expected to provide considerable information about the printer being installed. Again, this is not a routine that many geodes should be using.

SpoolGetDefaultPrinter() returns the number of the system-default printer. SpoolSetDefaultPrinter() makes the printer associated with the passed printer number the new system-default printer. Note that these routines are concerned with the system-default printer as opposed to the application-default printer. Most applications won't specify an application specific default printer. For these applications, the system-default printer will be the default. Of course, the user will still be allowed to select any printer, ignoring the default.


Up: GEOS SDK TechDocs | Up | Prev: 7.1 Spooler and Scheduling | Next: 7.3 Page Size Related Routines