简体   繁体   English

是否可以通过使用jtexarea.print();的POS打印机打印收据?

[英]Is it possible to print a reciept using a POS printer using jtexarea.print();?

I'm building an application that has to use a POS printer to print a receipt on a button click. 我正在构建一个必须使用POS打印机才能在单击按钮时打印收据的应用程序。

I've never used a printer with JAVA before, so I have no idea, but I've done some research and I'm thinking of either formatting my receipt in a jtextarea and then printing it using the print() method, 我以前从未在JAVA上使用过打印机,所以我不知道,但是我做了一些研究,我在考虑将收据格式化为jtextarea ,然后使用print()方法进行print()

or painting it to Graphics2D first using paint(g2d) and then printing it with a printer job using the Printable interface. 或先使用paint(g2d)将其paint(g2d)到Graphics2D,然后使用Printable界面通过打印机作业进行Printable

Which would be easier? 哪个会更容易? Thanks in advance. 提前致谢。

I've actually worked a lot with stuff like this. 我实际上已经在处理类似这样的事情。 I've tried printing with with Graphics2D which works fine but is very slow on a POS printer. 我曾尝试使用Graphics2D进行打印,该方法工作正常,但在POS打印机上速度很慢。 You usually want POS printers to be fast. 您通常希望POS打印机速度快。 POS printers have a serial communications interface for printing, which is how I'd recommend you to do it. POS打印机具有用于打印的串行通信接口,因此建议您这样做。 Have a look at: 看一下:

http://www.javapos.com http://www.javapos.com

It's a library for interfacing with POS peripherals. 这是一个用于与POS外设接口的库。 The documentation isn't the best. 文档不是最好的。 You will need javapos libraries, javapos drivers for your specific printer, serial communication libs (RXTX) etc. 您将需要javapos库,用于特定打印机的javapos驱动程序,串行通信库(RXTX)等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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