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
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);
?>
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.
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.
I realise this question is a little old but I recently had to perform this exact task and here is how I did it. Main server is a Cloud-Based PHP server which is not on the local network. On the local network we have another machine which is simply running WAMP and this script, the Zebra printer itself is also on the local network at IP 192.168.1.201:
Then, on the webpage generated by the cloud server we have some code which simply does an Ajax POST to the server on the local network, posting in the zpl_data to be printed.
Edit 2017
We've now moved things over to run through PrintNode (https://www.printnode.com/). We've found it to be really good so far, and allows us to print all kinds of documents without needing to use our own proxies, and also provide a whitelabelled installer so it looks like our own product. I'm not affiliated with PrintNode.
After hours of searchings I get the solutions :
After you install the printer on the needed IP:
In my case the command was:
Where: printer = Epson-Cofetarie
file = /home/clara/Desktop/txt.txt
file need Apsolute path
The
printer_open()
and related functions are not part of the standard PHP language; they are part of an extension.If you want to use them, you'll need to install the extension: See here for info on the printer extension.
However, please note that this extension is only available for PHP running on Windows.
If your server is not Windows, you will need to use an external program to send data to the printer. An example might look like this:
This info, and more can be found elsewhere on SO -- eg here: printing over network from PHP app
Hope that helps.
I hope, this simple code will resolve the problem,
e.g "\192.168.1.113[YOUR PRINTER NAME]";
<?php $file="barcode.zpl"; copy($file, "//192.168.1.113/ZDesigner GK420t"); ?>
Thank You