Using Printer Escapes

Your application uses escapes to communicate with the device driver associated with the printer. These sequences tell the device driver what to do, and also gather printer-specific information, such as page size, for the application. To send escape sequences to the device driver, the application uses the Escape function.

Summary: Use the Escape function to communicate with the printer.

For example, to tell the printer device driver to start a print request, use the Escape function with the STARTDOC escape. The following example sends the STARTDOC escape to the printer device context identified by the variable hPrinterDC; it starts a print request named My Print Request.

Escape(hPrinterDC, STARTDOC, 0, (LPSTR) “My Print Request”, 0L);

When sending output to the printer, you follow the same general rules as for other types of GDI output. If you are printing text, or primitives such as rectangles, arcs, and circles, you can send them directly to the printer device context. You can also send text and primitives to a memory device context. This lets you create complex images before sending them to the printer.