Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print a receipt through Receipt Printer from Web Page(.aspx)? [duplicate]

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.

like image 206
nightingale2k1 Avatar asked Feb 03 '10 14:02

nightingale2k1


People also ask

How do I print a receipt from Chrome?

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.


3 Answers

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.

like image 164
Cesar Avatar answered Oct 02 '22 06:10

Cesar


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

like image 21
Jeremy Thompson Avatar answered Oct 02 '22 06:10

Jeremy Thompson


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

like image 42
SOA Nerd Avatar answered Oct 02 '22 05:10

SOA Nerd