Page 1 of 1

help with printer

Posted: Wed Dec 20, 2006 3:17 pm
by Regit
im trying the following and for some reason it will not work

The code

Code: Select all

<?php
	print("testing the printer function");

	$handle = printer_open("\\\\10.2.5.28\\Canon");
	
	printer_set_option($handle, PRINTER_MODE, 'RAW');

	printer_write($handle, "Testing");

	printer_close("\\\\10.2.5.28\\Canon");
?>
And i get the following

Code: Select all

testing the printer function
Warning: printer_set_option(): supplied argument is not a valid Printer Handle resource in c:\Inetpub\wwwroot\testing fun\print.php on line 6

Warning: printer_write(): supplied argument is not a valid Printer Handle resource in c:\Inetpub\wwwroot\testing fun\print.php on line 8

Warning: printer_close(): supplied argument is not a valid Printer Handle resource in c:\Inetpub\wwwroot\testing fun\print.php on line 10
Am i doing something wrong? ive looked and looked but cant find anything that shows what is wrong, or needs to be correct. It appears to connect to the printer ok but nothing else.

I do have extension=php_printer.dll in the php.ini file

Posted: Wed Dec 20, 2006 5:57 pm
by printf
You need to give it the computer name, not the dotted ip address. Also the mode RAW will only write a single character T, because your not setting any options that RAW mode needs. You should use mode text, if writing a string!

1. So, go to My Computer >> right click Properties >> Network Identification >> Full Computer Name (without the ending dot).
2. Go to Start >> Settings >> Printers >> right click the printer you want to use >> scroll down and left click properties In the top box by the printer icon, copy that full name to your script, it should look something like this.

Code: Select all

<?php
	print 'testing the printer function';

	$handle = printer_open('\\\my-developer\\hp business inkjet 2300 series');
       
	printer_set_option($handle, PRINTER_MODE, 'text');

	printer_write($handle, 'This is a test!');

	printer_close($handle);
?>
Where as...

my-developers = will be changed to your full computer name or network share domain name (not ip)
hp business inkjet 2300 series = will be changed to the full network name of your printer