简体   繁体   中英

How can I send raw data to a printer in Mozilla Firefox? (Raw Print)

I have a PHP+MySQL web application to sell ticket in my officess.

I have dotmatrix printer (Panasonic KX-P1050) to print Tickets and bills.

My Ticket size is: 15cm X 25cm.

I want to send some text directly to Dot Matrix printer like Panasonic KXP-1050 without using true type fonts and windows' print dialog. As I know, this means: RAW Printing

Actualy, I can print to dot matrix "graphically", which is built-in in Windows, albeit slower. But I only want to print pure text with simple formattings which is faster than graphical printing.

I want to use this for printing bills or ticket on continuous-form paper.

I can use JavaScript or adobe flash(?) to send text to printer.

Once upon times, There was ActiveX sample for InternetExplorer on this link: http://www.xuebrothers.net/ax/activeprinter/interfaces.htm (now, this link doen't work)

Until now, I use Internet Explorer with that ActiveX & javascript to solve my request. But, now I want my web application can work with Mozilla Firefox. Because Firefox is better than Internet Explorer.

There is a link http://support.microsoft.com/?kbid=322091 that explains "How to send raw data to a printer by using Visual C# .NET"

How can I send raw data to aa printer in Mozilla Firefox?

I only know HTML, Javascript, PHP and MySQL. If solution is hard to understand for me, I can offer some fee for ready-made solution.

Regards, Nuri Akman

I did this in the past with a Java Applet.

++ Runs on major platforms and browsers

-- Client MUST install Java Runtime

More references:

how to send raw data to printer

Two suggestions to try

  1. Flash/ActionScript could be superior possibility since it's better (in my opinion) and more widely distributed than Java VM.
  2. Java applets

You won't be able to do this with Javascript since the browser security model wont let you access hardware devices directly for RAW printing. I'm pretty sure that you can't do this with Flash either since I don't think you can elevate to full trust (and the APIs are OS neutral). If you hosting locally then perhaps you can do this with PHP or your own C++ module server side.

The only alternative to ActiveX is Java if you want to target raw printing on all platforms. (not including mobile).

Here's a ready solution: http://code.google.com/p/jzebra

There are some slight disadvantages to using Java applets (slow load times, security warning, plugin blocking), but for locally connected printers, it may be your only option that doesn't leverage ActiveX.

Edit: the java solution works on IE too.

I think in the case of intranet application we can send the printer codes from server to shared printer on client. I'm sure this will work and i will try this on my next project.

只需使用客户端或服务器端处理在页面上显示所需内容,然后使用

<body onload="window.print();">...</body>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM