using System; using System.Data; using Honeywell.Mobility.Print; namespace SmartDeviceProject1 { class Class1 { static LinePrinter lp = null; static void Main(string[] args) { lp = new LinePrinter("ITC_CONFIG.XML","PR2Bt_40COL"); lp.Open(); lp.Write("Hello World"); lp.NewLine(); lp.Close(); } } }
The line using Honeywell.Mobility.Print gives access to the LinePrinter class.
LinePrinter lp = null declares a variable as a line printer object.
lp = new LinePrinter (... creates and initializes the LinePrinter and takes two string arguments: the name of and path to the printer configuration file, and a printer reference within the configuration file that is the target of the printing.
To use a different printer than the PR2, modify the LinePrinter constructor call to list the correct printer from the configuration file in the second parameter ("PR2Bt_40COL" in the example).
lp.Open() opens the communications link between the two devices.
lp.Write("Hello World") sends a string to the print buffer. Because of LinePrinter and hardware buffering, printing will not start until the application calls a NewLine method.
lp.NewLine() transfers the text follwed by a line feed code to the printer. After this line the printer should start printing the string.
lp.Close() closes the connection to the printer and releases handles. For NPCP printing, Close will not return until all pending text has been printed. For other printing methods, Close will return within a couple of seconds of being called. The printer may still continue to print for up to a couple minutes until its buffer is empty.
Next » Tutorial Part 2
Back » LinePrinter Tutorial