Java USB POS 打印 - Linux
您好,我在尝试在 Linux POS 中使用 USB 打印机时遇到问题。目前我们只有串行打印机,我们使用串行端口解决打印问题,但我们正在购买新的打印机型号,它是USB,所以我的代码不再工作。 我发现java打印api对我来说不是一个好的解决方案,因为我有3个不同版本的linux操作系统,并且很难获得驱动程序来安装打印线轴以供linux中的java api使用。 有人遇到过这个问题吗?直接用usb怎么样?
Hi I'm having a problem trying to use USB printers in my linux POS. Currently we only have serial printers and we solve the printing issue using the serial port, but we are buying a new printer model and it's USB, so my code is no longer working.
I find out that java printing api is not good solution for me, because I have 3 different versions of linux operating system, and is very difficult to get drivers to install a printing spool to be use by the java api in linux.
Anyone has faced this problem? What about using usb directly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,我前段时间遇到过这个问题。不,您不能直接将 USB 读取为 COM 端口,您需要一个能够“理解”打印机通信方式的驱动程序。我们确实做了你不想做的事。我们创建了一个可以通过 COM PORT 打印的模块和一个可以使用 Java 打印 API 进行打印的模块。
老实说,我不认为在 Linux 中使用驱动程序有太大问题,这种设备通常与通用原始打印驱动程序一起使用,并且较新的型号包括对 Linux 终端的本机支持。使用 Java 打印 API 的另一个优点是可以在远程终端中打印,这几乎是所有客户都想要的。
Yes, I had this problem some time ago. No, you can't read directly the USB as a COM port, you need a driver that "understands" the way your printer talk. We did exactly what you don't want to do. We created a module that can print via COM PORT and a module that can print using Java printing API.
To be honest I don't find too problematic the use of drivers in linux, this kind of devices ususally work with generic raw printing drivers and the newer models include native support to linux terminals. Another advantage of using the Java printing api is that you can print in remote terminals, thing that almost all customers want.
new FileOutputStream("/dev/usb/lp0");
然后写入它应该可以做到,至少对于 ESC/POS 来说。new FileOutputStream("/dev/usb/lp0");
and then write to it should do it, at least for ESC/POS.