How to print from web application to receipt printer?

前端 未结 3 809
慢半拍i
慢半拍i 2020-12-13 11:28

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

相关标签:
3条回答
  • 2020-12-13 11:58

    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

    0 讨论(0)
  • 2020-12-13 12:02

    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.

    0 讨论(0)
  • 2020-12-13 12:16

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

    0 讨论(0)
提交回复
热议问题