Receipt Printer - print from webpage

让人想犯罪 __ 提交于 2019-12-18 13:48:20

问题


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/


回答1:


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.




回答2:


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":

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>




回答3:


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.

Here you can get more information.



来源:https://stackoverflow.com/questions/5232531/receipt-printer-print-from-webpage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!