I have a POS application built on c# visual studio 2012.
The POS solution is based on transaction of money from a consumer to the beneficiary. My POS solution gives a printout for every transaction occurred.I am using an EPSON TM-T81 thermal printer. The EPSON api for c# are being used. Right now I send the commands for printing directly to the printer as RAW data. But I want to use the windows spooler to send the commands for print.
The api provided by EPSON only gives code for RAW printing. There is a function for Asynchronous Print, but does not give the required result.My c# application is based on socket communication between a main server and a couple of hand-held devices which carry out the transaction of money. For this I am using a asynchronous socket server. Upto this part there is no problem, but If there are 2 transactions occurring at the same time, the printer only prints a single receipt. I have put a sleep() for about 2 sec in between 2 prints, but still this is not the way and will cause problems later.
My code for sending print commands using c# :
m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|N" + "userID : " + cardId + "\n");
m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|N" + "Member : " + user_name + "\n");
I am initializing the printer earlier :
PosExplorer posExplorer = new PosExplorer();
DeviceInfo deviceInfo = null;
try
{
deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName);
m_Printer = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
}
catch (Exception)
{
}
//Register OutputCompleteEventHandler.
AddOutputComplete(m_Printer);
//Open the device
m_Printer.Open();
try
{
//Get the exclusive control right for the opened device.
//Then the device is disable from other application.
m_Printer.Claim(1000);
Console.WriteLine("Printer claimed");
}
catch (Exception e)
{
Console.WriteLine("Printer Not claimed");
}
I want to shift from direct RAW printing to using the windows spooler on c#.
I had a look at the windows spooler api : Windows Spooler API But do not know how to implement my format and printer using the same.
I would appreciate any help provided.