Receipt Printer - print from webpage

2019-02-07 19:57发布

I have a receipt Printer and it connected to Serial COM1 on to my comuter.

I am trying to print a receipt from the webpage and when it print... it just a blank without any text. (Blank receipt!). It work fine on IE8 but not working on Firefox 3.6

I have an Epson TM-T88II Printer and using "Generic / Text" driver on Windows 7.

What is the solution to this?

HTML code of receipt:

<html>
<head>
    <title></title>
</head>
<body>
    <div>
        <div>Company Name</div>
        <div>Customer Name</div>
        <div>Order No</div>
        <div>1 x Item</div>
        <div>1 x Item</div>
        <div>1 x Item</div>
        <div>12.00</div>
    </div>
</body>
</html>

http://jsfiddle.net/bu49K/

3条回答
姐就是有狂的资本
2楼-- · 2019-02-07 20:10

If you are willing to load a java applet, jzebra can print directly to the Epsom TM series thermal printers to COM1 port using the Generic Text driver as you've described.

https://github.com/qzind/qz-print

The problem you are encountering is not uncommon. Generic/Text bypasses the PostScript (2D) capabilities of the Epson print driver.

If using Generic/Text, Epson uses the ESC/P programming language. You will find many tutorials on the internet for printing in this format, and jzebra has more information about this style of "RAW" printing here:

https://github.com/qzind/qz-print/wiki/Raw-Printing

Edit:

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 qz-print library, put the jar file in the project directory and hey presto:

<input type=button onClick="print()" value="Print">
<applet id="qz" code="qz.PrintApplet.class" archive="./qz-print.jar" width="100" height="100">
      <param name="printer" value="zebra">
</applet>

<script>
      function print() {
       qz.append("PRINTED USING JZEBRA\n");
       qz.print();
      }
</script>

enter image description here

查看更多
时光不老,我们不散
3楼-- · 2019-02-07 20:15

This is very old question, but it is still difficult to find a good solution. I used to use QZ Tray solution (as Tres Finocchiaro has described), but now I think I've found a better one that provides full control over the process:

  1. Register custom protocol (like "https", "http", "mailto") named, for instance, "print". It is done using registry editor in Windows.
  2. Write a custom protocol handing application which will be automatically executed by Windows when somebody is going to open a link like "print://any/parameters/go/here".
  3. Implement printing in your application. I'm using C# and built-in PrintDocument class, so it is extremely simple.

Now I can just create a link with href like "print://invoice/1234" and then parse this URI in your application and print whatever you need. It works even from a command line.

The printing result photo

Here you can get more information.

查看更多
干净又极端
4楼-- · 2019-02-07 20:35

a solution: Have a look at jQPrint

EDIT:

Have a look at jQuery or other javascript plugins that do this, try jQPrint if it's still supported or try searching if the link is broken. I realise this is an old answer and they type of answer that is no longer permitted. Hopefully this helps.

查看更多
登录 后发表回答