How to print from web application to receipt printer?
Asked Answered
T

3

14

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.

Tauro answered 3/2, 2010 at 14:15 Comment(0)
M
3

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.

Margertmargery answered 3/2, 2010 at 14:36 Comment(0)
C
3

To get this working, simply setup your receipt printer as the default printer and rename it as "zebra":

enter image description here

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>

enter image description here

Contrabassoon answered 26/5, 2013 at 4:12 Comment(3)
It's no so easy these days... update 45 from Oracle requires Java applets to be signed to run without prompting, so there's some costs involved with using QZ Print safely in a production environment.Remitter
@RobbieAverill is using qzpint websocket also has these limitations ?Sabir
@Sabir not sure. If you run the Java applet on the clients browser (which you'd need to do to interface to the printer) then it would probably need to be signed either wayRemitter
P
2

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

Pickaback answered 3/2, 2010 at 15:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.