I was asked by my client to print receipts on an Epson TM U220 (http://pos.epson.com/products/TM-U220.htm) from my web application. I have no idea how to do that. Are there any java applets or something else that I can use for printing? Should i use JasperReports? (Does JasperReports help to cope with this problem?) If there are flash apps that could be used, I have no objection to using that.
I am using Grails for my web apps.
From Chrome, select the menu icon that appears as three dots in the top right of your browser then select Print from the options in the list.
You don't need an applet, from a grails controller you may use any Java library. Use the Java printing services available to the runtime in javax.print. This is assuming that the printer is installed where the grails runtime is running.
To get this working, simply setup your receipt printer as the default printer and rename it as "zebra":
Then simply download the jZebra library, put the jar file in the project directory and hey presto:
<input type=button onClick="print()" value="Print">
<applet name="jzebra" code="jzebra.PrintApplet.class" archive="./jzebra.jar" width="100" height="100">
<param name="printer" value="zebra">
</applet>
<script>
function print() {
document.jzebra.append("PRINTED USING JZEBRA\n");
document.jzebra.print();
}
</script>
I created an app to write to a receipt printer for a POS system a while back. The way we did it was to just open a printwriter that pipes to the correct receipt printer. We manually sent the character codes to the printer to create bold, underline, font changes, etc because of requirements from the client that we do it that way (there was another application that used these character codes and they wanted us to use them also).
If you don't want to go through the manual process like I did a good choice is JavaPOS. It has got alot of stuff related to printing to receipt printers (definately much more elegant than I described above). You'll find it at http://www.javapos.com/.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With