Printing on a thermal printer

  • Thread starter Thread starter Francisco Duran
  • Start date Start date
F

Francisco Duran

I am working in a .NET based Point of Sale solution. As a requirement I
need to print on thermal printers. I am looking for a recommendations or
best practices to achive this as the .NET Framework classes for printing are
not working very well. As a matter of fact, the .NET framework classes
don't work with the thermal printers I have access to, because they only
accept certain characters and they don't work very well with Graphics (true
type fonts?).

I need to know if there's another way to print, even if there are some
primitives to print a single line at a time. I don't need print previews or
printer selection windows as the only thing required is to send receipts to
the printer as soon as the point of sale receives the payment from the
customer.

Any link or code sample would be very appreciated or if you know a
third-party product that achieve the same goal please let me know.

Thanks in advance for your help.

Best Regards,

Francisco Duran
 
Hi,

This really is a Windows issue, not a framework issue. If the printer is
installed as a Generic Text Only printer, then Windows should "do the right
thing."

If your thermal printer is connected serially, then certainly you can use
any one of the serial IO classes that are available online (on in my book),
or any of the ActiveX serial controls (NETComm.ocx from my homepage, for
example) to print.

If your printer uses a parallel port connection, then you should be able to
use the same P/Invoke (Platform Invoke) API calls that are used in the
serial classes that I mentioned above to send data to the printer (use LPT1
instead of COM1 as the device name in the CreateFile call).

In any case, when using either serial or parallel printer methods that rely
on the Windows CreateFile API, the printer CANNOT be installed as a Windows
printer... Installed printer ports are opened exclusively by Windows when it
starts, and cannot be opened separately by your program.

There is one way to print to a parallel printer (I've done this, so I know
that it works) that is installed as a Windows printer, but bypassing the
Windows printing routines. This employs a device driver to manipulate the
IO ports used by the printer directly -- Windows had no idea that you are
doing this. I have written an ActiveX control for this purpose, and have
considered porting it to pure .NET (time/money has been an issue). This is
several hours of work that are pretty low priority right now.

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
 
Hi Francisco

I suggest keep looking for a better solution.

There is a way of sending a print job to the Windows printer queue that
contains whatever you like. For a POS printer this is likely to be raw Epson
ESC P commands, graphics data etc. The advantage is that the printer can
still be accessed correctly by multiple applications (Assuming you don't
leave it in some odd mode when your job completes).

The example I saw some time ago did this in C++, and you would probably need
to use PInvoke calls to do it from .NET. Unfortunately I can't remember
where I saw the example.

Regards

Ron
 
Back
Top