java 使用收据打印机打印收据

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32070941/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 19:35:41  来源:igfitidea点击:

Print receipt using receipt printer

javaprintingpoint-of-salejavapos

提问by Yunus Einsteinium

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.

我正在开发一个销售点应用程序,其中一项功能是在热敏/收据打印机中打印收据。目前我有一台 Datecs DPP-255 打印机。

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.

我尝试通过互联网搜索,发现 JavaPOS/UnifiedPOS 存在,但我找不到足够的文档来帮助我入门。请说明一下。

回答by informatik01

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):

这是一个用于测试的开源项目,也可以作为如何使用JavaPOS进行编程的参考(源代码可用):

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

这里还有一些托管在 GitHub 上的项目(请参阅源代码以获得想法和使用):



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.

注意:
为了使用 JavaPOS(现在是UnifiedPOS 规范的一部分,请参阅附录 B),Datecs DPP-255 设备的生产商必须提供相关的驱动程序。他们提供吗?JavaPOS - 是一个规范,因此必须有它的一些实现。

回答by Keiran van Vuuren

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

所以看起来这台打印机支持一种叫做ESC/POS的东西,它就像一个命令集,可以让你打印和格式化数据。网上有一些指南,这是我以前用过的一个: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.

请注意,打印机有时在它们支持的 ESC/POS 命令集方面略有不同,因此您可能需要进行一些反复试验。

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.

在将数据发送到打印机方面,这取决于它是什么类型的连接。对于串行,您应该能够使用 ESC/POS 命令集打开并写入该端口。

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 = "\u000A";etc.

并非您将发送的所有数据都是 ASCII 或 UTF 编码的,其中很多是您需要发送的二进制值。例如,要告诉打印机写一个新行,其十六进制值为0A。因此,在 Java 中,您需要将其指定为String s = "\u000A";等。

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

对于 Java,您需要从http://java.sun.com/products/javacomm/下载 Java Comm API

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

这里有一个教程:http: //www.java-samples.com/showtutorial.php?tutorialid =214

Hopefully this helps.

希望这会有所帮助。