Thursday, September 10, 2009

Pos .Net, PosPrinters and Nothing Happening

The other day I was working on some sample code using Pos .Net to print to a receipt printer. Try as I might, I could not get the code to print my text regardless of whether I used my Epson TM-T88IV or my TPG printer. My production code worked fine, but not the sample and I was stumped as to why.

Reading the Pos .Net SDK documentation I noticed it had several references to the way carriage return and line feed characters are processed and that sending one or the other would cause all previously buffered data to be printed. Nowhere did it say, however, that you must send one of the characters to get your text to print even though it turns out that including a \r\n on the end of my print data solved my problem.

I would have thought that if neither character was supplied the service object would print any buffered data when the PrintNormal method returned (except in Transactional printing mode), or at the very least when the Release() method was called. Since you can’t possibly print anything else after that without another call to the Claim method, it seems pretty obvious you’d want any previously buffered data printed before you finished with the printer. Flushing the buffer when Release is called would be good and expected behaviour, at least to my way of thinking. But apparently not.

So, the moral of the store is that if you’re printing with Pos .Net, but nothing is coming out of the printer and you’re not getting any errors, make sure you have a line feed somewhere in your print string (presumably at the end).

Something else that concerned me in the documentation for the Print Normal method was the part that talks about using the ValidateData method to determine if and how carriage return characters are processed. You just can’t take anything for granted.

Technorati Tags: ,,,,


  1. Hi Yort, I hope you can help me, I'm printing on epson TM-U950, I can print receipt, journal and slip, the issue is when the string parameter passed to PrintNormal method is too large the printer works ok on first sheet then an Exception is thrown "Out of slip form" and slip led keeps blinking until another slip form is inserted, the problem is I cant determine when the prints end and then execute BeginRemoval() EndRemoval() Any suggestion?

  2. Hi, I'd love to help but unfortunately it's been a few years since I did anything with POS .Net and I haven't used a slip printer in nearly 18 years (they're hardly used by anyone in the country where I live anymore). I don't have a solution for you, sorry.

    One thing I'm confused about is why you'd want to insert a second slip anyway. Pretty much the only thing I've seen slip printers used for are cheques and vouchers, and in either of those cases inserting a second cheque/voucher doesn't make sense. You only want one. *Perhaps* you should re-evaluate the slip printer is the best device to use?