Hi,
Need to print the report using php.
How to do this?
Need help in PHP Printer script
Moderator: General Moderators
-
rajsekar2u
- Forum Commoner
- Posts: 71
- Joined: Thu Nov 20, 2008 4:23 am
Re: Need help in PHP Printer script
You could use the javascript:printPage() function and include this in the php page
Re: Need help in PHP Printer script
PHP Manual: Printer
The printer functions are Windows-only.
Make sure php_printer.dll is enabled in php.ini.
Here is a simple example.
I don't know enough about this to troubleshoot for you.
Edit: This post was recovered from search engine cache.
The printer functions are Windows-only.
Make sure php_printer.dll is enabled in php.ini.
Here is a simple example.
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>';
?>Edit: This post was recovered from search engine cache.
Last edited by McInfo on Tue Jun 15, 2010 12:15 pm, edited 1 time in total.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Need help in PHP Printer script
The PHP print extension is for printing on the server machine, not the client machine. You will need to use javascript to prompt the client the print.
Re: Need help in PHP Printer script
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.
Edit: This post was recovered from search engine cache.