views:

68

answers:

2

I have this Zebra ZM400 Printer connected to the network (192.168.1.50). And I am trying to push a content to this printer directly from PHP.

This is the idea and I am just stuck without any way to do this. I tried the file_put_contents('192.168.1.50', $content) but with no success.

Would appreciate if anyone could please help me in sorting out this. Thank you :-)

.................................................................................................................................

Solution:

I printed using the LPR Protocol. No need to install driver or anything. The LPR Printing Class for PHP 5 can be downloaded from here:

http://www.phpclasses.org/package/2540-PHP-Abstraction-for-printing-documents.html

+3  A: 

I'm pretty sure just pushing text content over a socket will not work at all.

You will need to print over lpr is my guess. Install a print server like CUPS and you can send it using that...

webdestroya
The printer has an internal print server. Does that mean sending the content is possible? Thanks.
Nirmal
@Nirmal - A print server allows you to communicate using a print driver. Doing `file_put_contents` will never work.
webdestroya
@webdestroya - I don't have a machine to install Linux and CUPS. Just found that the internal Print Server accepts files over FTP. But the trouble is that it only allows active connections while PHP is trying to initiate a passive connection. I shall put up a separate question regarding that and post the link here. Thanks for your time!
Nirmal
At last I used the LPR printing protocol supported by the printer. The LPR Printing class for PHP can be found here: http://www.phpclasses.org/package/2540-PHP-Abstraction-for-printing-documents.html
Nirmal
A: 

Take a look at these PHP printer funtions

Note that

These functions are only available under Windows 9.x, ME, NT4 and 2000.

codaddict
And you have to install a PECL package.
NullUserException
I tried the php_printer.dll on PHP 5.3 and it creates a nightmare of 'Out of Memory' errors. You can read the whole thread here: http://www.spinics.net/lists/winphp/msg08651.html
Nirmal