Hi, am testing the print functions php has, with the following code snippet :
/ get the sample text /
$lipsum = file_get_contents('lipsum.txt');
/ open a connection to the printer /
$printer = printer_open();
printer_start_doc($printer, "Doc");
printer_start_page($printer);
/ font management /
$arial = printer_create_font("Arial", 148, 76, PRINTER_FW_MEDIUM, false, false, false, 0);
/ write the text to the print job /
printer_select_font($printer, $arial);
printer_draw_text($printer, $lipsum, 250, 500);
/ font management /
printer_delete_font($arial);
/ close the connection /
printer_end_page($printer);
printer_end_doc($printer);
printer_close($printer);
lipsum.txt is just a string of sample text.
My problem is thus : When I access the page in my web browser with my server's default printer passed as a parameter in printer_open() [so, printer_open("HP LaserJet 1160")], it actually prints successfully.
However, once I remove the printer name from the function (understand from php.net manual that it would cause php to detect the default printer set in Windows), it gives the error :
Warning: printer_open() [functionprinter-open]: couldn't connect to the printer [,,,,] in C:\wamp\www\testprinting.php on line 6
Have been trying to solve this for hours, to no avail. Would appreciate any light you could shed on this. =)
Thanks!