Need help in PHP Printer script
Posted: Sat Apr 25, 2009 9:17 am
Hi,
Need to print the report using php.
How to do this?
Need to print the report using php.
How to do this?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?php
if (!function_exists('printer_open'))
die('<p style="color: red">No printer support detected.</p>');
else
echo '<p style="color: green">Printer support detected.</p>';
$printer_name = '\\\\192.168.0.1\\Canon S300';
if ($ph = printer_open($printer_name))
{
echo '<p style="color: green">Successfully opened printer: '.$printer_name.'</p>';
$text = 'Text to send to the printer.';
echo "<pre>$text</pre>";
if (printer_write($ph, $text))
echo '<p style="color: green">Successfully sent text to printer.</p>';
else
echo '<p style="color: red">Failed to send text to printer.</p>';
printer_close($ph);
}
else
echo '<p style="color: red">Could not open printer: '.$printer_name.'</p>';
?>That condition was not defined in the request. I probably should have mentioned that in my response, though.John Cartwright wrote:The PHP print extension is for printing on the server machine, not the client machine.