PHP Thermal Printing Client-Side

邮差的信 提交于 2019-12-24 08:58:21

问题


I've got a Epson Thermal printer, model TM-T20 which I'm setting up for clients.

Our webserver is a linux server, and the client machines will be Windows machines.

Is it possible with php, to directly control the thermal printer attached to the clients computer?

I have looked at javascripts window.print(), but that is not what I want, if possible I want to bypass the print dialog.

Thanks, Tony


回答1:


No. PHP has absolutely nothing to do at all with the client's printer. If the printer was attached to the machine the PHP script is running on (i.e. the server), there may be something you could do. As it is, PHP only sends text to the client. From there, the client's browser and printer software has to handle it.

Alternatively, if the Windows box ran a print server exposing the printer that PHP could talk to over the network, you could talk to the printer directly. But that wouldn't be a normal PHP server/client relationship anymore.




回答2:


printing from php isn't that easy, most web apps i have seen generate a pdf and and the clients print that.

have a look at http://www.vendhq.com/ they do a point of sale app for shops, and have something you need to download and install to print till dockets via a receipt printer. it might give you some inspiration




回答3:


I have done exactly this before. It was quite tricky, using a ubuntu server on the workplace's LAN and a thermal printer on another ubuntu computer in the shipping area. That computer was running a php service listening to a port and was headless, hiding inside the cabinetry.

The business's internal web php "application" on the LAN server would coordinate with their e-commerce and UPS.com to print a shipping label. I forgot how UPS sent it but we used imagemagik to tweak the final image to the perfect pixel width. Then the LAN server would connect to the target's php socket server and it would send the proper commands to the serial port that the printer was connected to, along with the image data.

To call that solution madhatterey is an understatement... but was quite amazing to have labels appear magically upon "shipping" an order. No print dialog or anything. Cheapest solution is get an Atom box that can run Ubuntu and get a printer with a ppd file that works. Then just queue it up properly. Same concept as remote printing in linux.

You could possibly do the print request from a webpage's AJAX request and not need the extra infrastructure (or target computer's php socket server).



来源:https://stackoverflow.com/questions/5725054/php-thermal-printing-client-side

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