I am trying to connect to my printer which is on another machine through this code
$handle = printer_open("\\\\xxx.xxx.xxx.xxx\\Canon MF4320-4350");
if($handle)
echo "connected";
else
echo "not connected";
and getting the error
Fatal error: Call to undefined function printer_open() in C:\wamp\www\print\index.php on line 3
I have installed the php_printer.dll but it is not showing it under phpinfo()
. Using PHP version 5.3.0
how can i connect to the printer and make my printer_open()
method work??
If you are using PHP 5.3/ 5.4/ 5.5 in WAMP, here is how you setup printer.
Create a file with the following code and test it:
<?php
$printer_name = "Your Printer Name exactly as it is";
$handle = printer_open($printer_name);
printer_start_doc($handle, "My Document");
printer_start_page($handle);
$font = printer_create_font("Arial", 100, 100, 400, false, false, false, 0);
printer_select_font($handle, $font);
printer_draw_text($handle, 'This sentence should be printed.', 100, 400);
printer_delete_font($font);
printer_end_page($handle);
printer_end_doc($handle);
printer_close($handle);
If the above does not work, try with nts version of the php_printer.dll file as mentioned in step two. remember to restart server after deleting the previous file, pasting the new file.
I have a similar problem. This is what I have figured out so far.
Make sure that you have a php_printer.dll matching your php compile version in your extension folder ( php/ext/ ). Use this link for downloading the file.
add the following in your php.ini file:
printer.default_printer=PHP_INI_ALL
extension=php_printer.dll
The errors have disappeared but the file is still not printing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With