note 89731 added to function.printer-open

From: Date: Fri, 20 Mar 2009 18:09:00 +0000
Subject: note 89731 added to function.printer-open
Groups: php.notes 
Request: Send a blank email to php-notes+get-152218@lists.php.net to get a copy of this message
I had been playing around with trying to get PHP to print to a network server off and on for quite some time, and I finally came across somebody who had the piece of the puzzle I've been missing. Like I said, the printer I've been trying to print to is a network printer, so I had been trying to open the printer as follows: printer_open("\\\\servername\\printername"); What I had been missing is that the function needed the internet host name of the server, which includes the domain name. So, let's say my print server was called "PServer" and my network's domain was called php.net: printer_open("\\\\Pserver.php.net\\printername"); This will more than likely work, then you can open and print a file as follows: $printer = "\\\\Pserver.php.net\\printername"); if($ph = printer_open($printer)) { // Get file contents $fh = fopen("filename.ext", "rb"); $content = fread($fh, filesize("filename.ext")); fclose($fh); // Set print mode to RAW and send PDF to printer printer_set_option($ph, PRINTER_MODE, "RAW"); printer_write($ph, $content); printer_close($ph); } else "Couldn't connect..."; ---- Server IP: 209.41.74.194 Probable Submitter: 68.156.145.10 ---- Manual Page -- http://www.php.net/manual/en/function.printer-open.php Edit -- https://master.php.net/note/edit/89731 Del: integrated -- https://master.php.net/note/delete/89731/integrated Del: useless -- https://master.php.net/note/delete/89731/useless Del: bad code -- https://master.php.net/note/delete/89731/bad+code Del: spam -- https://master.php.net/note/delete/89731/spam Del: non-english -- https://master.php.net/note/delete/89731/non-english Del: in docs -- https://master.php.net/note/delete/89731/in+docs Del: other reasons-- https://master.php.net/note/delete/89731 Reject -- https://master.php.net/note/reject/89731 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#152218) next »