A Windows printer driver consists of code and data. The code includes functions which configure the printer, retrieve printer capabilities, and render output. The data includes structures which describe the supported printer resolutions, color capabilities, device-resident fonts, curve-drawing capabilities, line-drawing capabilities, and so on.
All Windows printer drivers must support 24 required functions that are called by Windows GDI. These functions initialize the device, return device data, set the printer mode, and generate output. The following sections briefly describe these functions. For more information about these functions, see the Microsoft Windows Device Driver Adaptation Guide.
Initialization Functions
The initialization functions start and stop print jobs, allocate memory for a driver's data structures, deallocate memory that was used by a driver's data structures, and so on. The following briefly describes each function.
Function | Description |
Control | The Control function performs device-dependent operations such as starting a print job, canceling a print job, processing a new band of bitmap data, and so on. |
Disable | The Disable function deallocates memory used by the printer driver's data structures, and unloads the driver from memory if no other device contexts (DCs) exist for this device. |
Enable | The Enable function allocates memory for and initializes the members within the driver's PDEVICE data structure. This data structure contains device-dependent data and device-state information. |
WEP | The WEP (Windows Exit Program) function signals that the driver DLL will be removed from memory, or signals that Windows is shutting down. |
Information Functions
The information functions retrieve color, font, pen, and brush information for a printer. The following briefly describes each function.
Function | Description |
ColorInfo | The ColorInfo function translates physical colors to logical colors and logical colors to physical colors. |
DevGetCharWidth | The DevGetCharWidth function returns width values for characters in a given printer font. |
DeviceBitmap | The DeviceBitmap function is not supported in the current release of Windows. It must be implemented as a stub function. |
EnumDFonts | The EnumDFonts function enumerates the fonts available on a printer. |
EnumObj | The EnumObj function enumerates the pens and brushes (if any) which are available on a printer. |
Output Functions
The output functions render output on a printer. The following briefly describes each function.
Function | Description |
DevBitBlt | The DevBitBlt function sets pels on a page of printer paper. These pels correspond to bits in a source bitmap. |
DevExtTextOut | The DevExtTextOut function renders text as well as a background pattern. |
Output | The Output function renders a shape on a page of printer paper. |
Pixel | The Pixel function sets a single pel on a page of printer paper. |
ScanLR | The ScanLR function sets pels that appear on a single row or scan. |
StrBlt | The StrBlt function renders scaled bitmaps. |
Attribute Functions
The attribute functions initialize data structures for the printer driver. The following briefly describes each function.
Function | Description |
RealizeObject | The RealizeObject function initializes a data structure for the specified pen, brush, font, and so on. |
SetAttribute | The SetAttribute function is not supported in the current release of Windows. It must be implemented as a stub function. |
Printer-Mode Functions
The printer-mode functions display special dialog boxes. The following briefly describes each function.
Function | Description |
DeviceMode | The DeviceMode function displays a dialog box that allows a user to select printer options such as paper size, paper orientation, output quality, and so on. |
ExtDeviceMode | The ExtDeviceMode function also displays a dialog box that allows a user to select printer options such as paper size, paper orientation, output quality, and so on. Printer drivers written for Windows 3.x and later versions support this function. |
Printer-Escape Functions
The printer-escape functions support device-specific operations. The following briefly describes these escape functions.
Escape function | Description |
ABORTDOC | The ABORTDOC escape function signals the abnormal cancellation of a print job. |
BANDINFO | The BANDINFO escape function returns information about a band of bitmap data. |
ENDDOC | The ENDDOC escape function signals the end of a print job. |
NEXTBAND | The NEXTBAND escape function prints a band of bitmap data. |
QUERYESCSUPPORT | The QUERYESCSUPPORT escape function specifies whether the driver supports a specified escape. |
SETABORTDOC | The SETABORTDOC escape function calls an application's cancellation procedure. |
STARTDOC | The STARTDOC escape function signals the beginning of a print job. |
The previous list of printer escapes is a list of escapes supported by the Microsoft Windows Universal Printer Driver (UNIDRV.DLL). It is not a comprehensive list of all Windows escape functions. Most of the escape functions now have equivalent Windows API functions with Windows 3.1. The escapes are supported for backward compatibility, but application developers are encouraged to start using the new API calls.
There are two fundamental data structures used by GDI and a Windows printer driver: They are the GDIINFO and the PDEVICE data structures. The members of the GDIINFO data structure are initialized by Windows, and the members of the PDEVICE data structure are initialized by the printer driver.
GDIINFO Structure
The GDIINFO data structure contains device data required by GDI. This structure has the following format:
typedef struct _GDIINFO {
int dpVersion
int dpTechnology
int dpHorzSize
int dpVertSize
int dpHorzRes
int dpVertRes
int dpBitsPixel
int dpPlanes
int dpNumBrushes
int dpNumPens
int futureuse
int dpNumFonts
int dpNumColors
int dpDEVICEsize
unsigned dpCurves
unsigned dpLines
unsigned dpPolygonals
unsigned dpText
unsigned dpClip
unsigned dpRaster
int dpAspectX
int dpAspectY
int dpAspectXY
int dpStyleLen
POINT dpMLoWin
POINT dpMLoVpt
POINT dpMHiWin
POINT dpMHiVpt
POINT dpELoWin
POINT dpELoVpt
POINT dpEHiWin
POINT dpEHiVpt
POINT dpTwpWin
POINT dpTwpVpt
short int dpLogPixelsX
short int dpLogPixelsY
short int dpDCManage
short int dpCaps1
long int dpSpotSizeX
long int dpSpotSizeY
short int dpPalColors
short int dpPalReserved
short int dpPalResolution
} GDIINFO;
This data structure contains three types of data:
Driver-management data
Driver-capabilities data
Driver-dimension data
The driver-management data specifies how GDI should manage multiple device contexts for a given driver.
The driver-capabilities data specifies physical capabilities of the device such as the number of predefined brushes and pens, the number of pure colors that the device supports, the device's curve-, line-, and polygon-rendering capabilities, and so on.
The driver-dimension data specifies the physical dimensions of the printable portion of a piece of printer paper, the number of bits required to represent a single dot on the page, the aspect ratio, and so on.
PDEVICE Structure
The PDEVICE data structure contains data that describes the current device context to the driver. This data includes an identifier for the current device font (if one is selected), a value specifying the output mode (portrait or landscape), an identifier for the selected paper tray, paper size, and so on. The format of this structure is device dependent.