Printing in Raw Mode

Printing in "Raw" Mode

Using GDI+ to generate printed pages is pretty straightforward. For complex pages, you may have to do a lot of positioning and measuring of text strings and whatnot, but it all boils down to "draw this text or this shape at this position."

Sadly, not all printers support the application-to-printer-via-GDI-and-Printish way of doing things. This is especially true of printers used to print thermal credit card receipts at your favorite pizza place. Although some of these printers may have Windows drivers, they are really designed for direct communication with an application via their special "escape sequence" language. For such printers, you need to write directly to the printer in "raw" mode, where you control exactly which characters get sent to the printer. (Actually, you don't have to go directly to the printer. You can still write to the printer's queue, and let Windows manage the scheduling of the print job.)

It is with even more sadness that I must inform you of .NET's lack of raw printer support. Although there is a DLL included with Windows that enables this direct printing method, a managed .NET wrapper for it does not ship with the Framework. You, and other overburdened programmers everywhere, must take up the charge yourselves.

Well, it's not all that bad. Microsoft and other developers have published code that maps the unmanaged DLL calls to managed equivalents. We'll be using a variation of some of this code in the Library Project in this chapter to support the printing of check-out slips, paper receipts that let a patron know which items were just checked out and when they are all due back.

Start-to-Finish Visual Basic 2005. Learn Visual Basic 2005 as You Design and Develop a Complete Application
Start-to-Finish Visual Basic 2005: Learn Visual Basic 2005 as You Design and Develop a Complete Application
ISBN: 0321398009
EAN: 2147483647
Year: 2006
Pages: 247
Authors: Tim Patrick

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: