简体   繁体   中英

Print receipt using receipt printer

I am developing a Point Of Sale application, and one of the functionality is to print receipt in a thermal/receipt printer. Currently I have a Datecs DPP-255 printer.

I have no idea where to begin my quest.

I tried search through internet, found out that JavaPOS/UnifiedPOS exists but I couldn't find enough documentation to get me started. Please shed some light.

Here is an open source project for testing, that may also be used as a reference on how to program using JavaPOS (source code available):

Also here are some projects hosted on GitHub (see the source code to get the idea and to play with):


Related links:


NOTE:
in order to utilize JavaPOS (which is now a part of the UnifiedPOS specification , see Appendix B ), the producer of your Datecs DPP-255 device must provide the related drivers. Are they provided? JavaPOS - is a specification , so accordingly there must be some implementation of it.

So it looks like this printer supports something called ESC/POS, which is like a command set that allows you to print and format data. There are a few guides available online, this is one I've used before: http://www.starmicronics.com/support/mannualfolder/escpos_cm_en.pdf

Note that printers sometimes subtly differ in which command sets from ESC/POS they support, so you might have a bit of trial and error on your hands.

In terms of sending that data to the printer, it depends on what type of connection it is. For serial, you should just be able to open and write to that port, using the ESC/POS command set.

Not all of the data you will send will be ASCII or UTF encoded, a lot of them are binary values you need to send. So for example, to tell the printer to write a new line, the Hex value for that is 0A . So in Java you would need to specify that as String s = "\ "; etc.

For java you will need to download the Java Comm API from http://java.sun.com/products/javacomm/

There is a tutorial on this here: http://www.java-samples.com/showtutorial.php?tutorialid=214

Hopefully this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM