Question

Below are my code:

PosExplorer posExplorer = new PosExplorer();
DeviceCollection receiptPrinterDevices = posExplorer.GetDevices(DeviceType.PosPrinter);
DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter,"SRP2");
PosPrinter printer = (PosPrinter)posExplorer.CreateInstance(receiptPrinterDevice);

printer.Open();
printer.Claim(10000);
printer.DeviceEnabled = true;
printer.PrintNormal(PrinterStation.Receipt, "test print 1");

I debug and everything went through without exception, already confirmed also that the printer targeted is the correct one, however the printer is not printing anything. Is there any step that I did wrong? Any guidance is greatly appreciated. Thanks


If it helps, My Printer Interface via Ethernet to a specific IP.

Was it helpful?

Solution

The problem appears to be that you are not sending a new line character (\n) at the end of your PrintNormal string, without it the service object will just buffer the line data, waiting until it sees the \n before sending the data to the device.

printer.PrintNormal(PrinterStation.Receipt, "test print 1\n"); 

From the POS for .net Documentation on PrintNormal

Newline / Line Feed (10 Decimal)

Print any data in the line buffer, and feed to the next print line. (A carriage return is not required in order to print the line.)

This is because the printer must print one complete line at a time, so it waits until you tell it that you have completed a line before starting to print, this allows you to use 2 or more PrintNormal calls for a single line of printout to build up the line data if needed (e.g. in a loop).

I have ran the below code on a networked POS Printer (Tysso PRP-250) and with the \n it prints the line, without it it does not.

PosExplorer posExplorer = new PosExplorer();
DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter, "SRP2");
PosPrinter printer = posExplorer.CreateInstance(receiptPrinterDevice) as PosPrinter;

printer.Open();
printer.Claim(10000);
if (printer.Claimed) 
{
    printer.DeviceEnabled = true;
    printer.PrintNormal(PrinterStation.Receipt, "test print 1\n");
    printer.DeviceEnabled = false;   
}
printer.Release();
printer.Close();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top