tags:

views:

378

answers:

2

Hi all,

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,

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.

A: 

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

Noon Silk
no, I connect it directly to my pc. I checked the printer, the port is LTP1:(
Ke CAI
+1  A: 

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

Brian Agnew
yes, I tried. No luck.
Ke CAI
Can you print to the printer normally, outside of a Java program? Does it show up as a printer from the OS?
Nate
See my comment re. javacomm above. Perhaps this is of use.
Brian Agnew
I think Thermal Receipt Printer is different from the printers we use everyday. The printer was installed successfully in Windows 7. But the print test cannot perform successfully:( I tried java comm, still doesn't work.
Ke CAI