开发者

Java and thermal receipt printer [closed]

开发者 https://www.devze.com 2022-12-19 21:49 出处:网络
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is not generally applic
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago.

Does anyone know how to print receipt use Java? I have googled for a long time. It seems Java POS should be a good solution. I have a quick look at it and it looks need the printer's Java driver. My printer is a cheap one, support ESC, but only have Windows driver.

I also tried:

 FileWriter out = new FileWriter("LPT1");

It does not work,

开发者_JS百科

java.io.FileNotFoundException: lpt1 (The system cannot find the file specified)

Printable does not work neither.

Does any one know how to do this? Thanks.


Is the Java Print Service API of use ? If not, perhaps the javacomm package since you're writing to a serial port.


The proper syntax is as follows:

FileWriter out = new FileWriter("LPT1:");

There was a colon missing.


Does it happen to be an IP Printer? If so, they generally listen on port 9100, and you can just write to that directly (text data) and it will print. You'll want to look up appropriate escape sequences, to do various things (cut, for example).


The best way to handle these things is via JavaPOS APIs; but even then, you can still get stuck when the Maker of your hardware does not provide the appropriate drivers, in which case you are stuck at serial ports. Give JavaPOS a look, it might make your work very easy.

JavaPos Website

0

精彩评论

暂无评论...
验证码 换一张
取 消