用php打印到Zebra打印机 [英] Print to Zebra printer in php

查看:405
本文介绍了用php打印到Zebra打印机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找使用RAW端口9100从php网页打印到zebra IP打印机的正确代码.有人知道这是否可行吗?我需要将ZPL格式的输出字符串直接发送到ZM400标签打印机.我搜索了高低,我发现的最接近的是:

Looking for the proper code to print from php web page to a zebra IP printer using RAW port 9100. Does anyone know if this is possible? I need to send a string in ZPL formatted output direct to ZM400 label printer. I've searched high and low, the closest I've found is this: Print directly to network printer using php

这似乎非常接近我的需求,但是当我的php页面点击该代码时,它什么也没做.这是我使用的代码:

It seems very close to what I need, but when my php page hits that code, it doesn't do anything. Here's the code I used:

<?php 
     $handle = printer_open('\\\\192.168.2.206:9100\\'); 
     printer_set_option($handle, PRINTER_MODE, "RAW");
     printer_write($handle, "TEXT To print"); 
     printer_close($handle);
?>

推荐答案

如果您希望将ZPL发送到打印机,则不一定需要专用的打印库.您只需要打开该打印机的插座,然后直接发送您的ZPL.与打印机特定问题相反,这更多是一个通用的PHP套接字通信问题.

If you're looking to send ZPL to the printer, you don't necessarily need a dedicated printing library. You just need to open up a socket to that printer and send your ZPL directly. This is more of a general PHP socket-communication question as opposed to a printer-specific question.

如果托管您的Web应用程序的服务器和打印机位于同一网络上,则您将能够打开套接字并发送ZPL.但是,如果您的打印机和Web应用程序服务器位于不同的网络上,则在没有其他浏览器插件或附加组件的情况下,您将无法在该型号打印机上通过套接字进行打印.一般来说,通过网站访问远程打印机(或任何设备)是一种安全隐患.

If the server hosting your web app and the printers are on the same network, then you will be able to open the socket and send the ZPL. If, however, your printers and web app server are on different networks, you will not be able to print over sockets, on that model printer, without additional browser plugins or add-ons. Generally speaking, accessing a remote printer (or any device) via a web-site is a security risk.

这篇关于用php打印到Zebra打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆