简体   繁体   中英

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.

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,

or painting it to Graphics2D first using paint(g2d) and then printing it with a printer job using the Printable interface.

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. You usually want POS printers to be fast. POS printers have a serial communications interface for printing, which is how I'd recommend you to do it. Have a look at:

http://www.javapos.com

It's a library for interfacing with POS peripherals. The documentation isn't the best. You will need javapos libraries, javapos drivers for your specific printer, serial communication libs (RXTX) etc.

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