|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-11-21 05:30 UTC] rich at dwell dot co dot uk
Description:
------------
There is a problem with the php_printer.dll.
Printing to a local printer is fine although I find that some of the options in printer_set_option do not seem to work.
On any share network printer, however, PHP gives warning about not being able to allocate the print job and then terminates.
I can in some cases work around this by outputing to a file and then calling the external program print.exe to print the file, but this is only useful for printers with there own proprietory language like label printers.
Obviously this is not a rights issue as I am printing to the printer using print.exe which runs under IUSR privileges.
Reproduce code:
---------------
<?php
$handle = printer_open("\\\\Warehouse\\whlaser");
printer_start_doc($handle, "");
printer_start_page($handle);
$font = printer_create_font("Arial", 100, 50, PRINTER_FW_MEDIUM, false, false, false, 0);
printer_select_font($handle, $font);
printer_draw_text($handle, "PHP is simply cool", 400, 400);
printer_delete_font($font);
printer_end_page($handle);
printer_end_doc($handle);
printer_close($handle);
?>
Expected result:
----------------
The network printer should output "PHP is simply cool" as it does on a locally connected printer.
Actual result:
--------------
Warning: couldn't allocate new print job in c:\inetpub\wwwroot\test\unused routines\print.php on line 4
Warning: couldn't start a new page in c:\inetpub\wwwroot\test\unused routines\print.php on line 5
Warning: couldn't end the page in c:\inetpub\wwwroot\test\unused routines\print.php on line 15
Fatal error: couldn't terminate print job in c:\inetpub\wwwroot\test\unused routines\print.php on line 17
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 20:00:01 2025 UTC |
I have a slightly different problem (although I am able to recreate the problem you have). PHP/Apache/MySQL is running on a Win2003 server computer. The label printer is running on an XP machine on the network. I have installed the drivers locally on the Apache machine, so Windows should handle the network communication. When I print the document from PHP as follows : printer_start_doc($print); printer_start_page($print); $font = printer_create_font("Tahoma",($h*0.6),($h*0.6*0.8),400,false,false,false,0); printer_select_font($print, $font); printer_draw_text($print, $pname, 0, $h*0.5); printer_draw_text($print, $punits, 0, $h*1.25); printer_draw_text($print, $ser, 0, $h*2); printer_delete_font($font); printer_end_page($print); printer_end_doc($print); The document goes to the printer queue, but does not print. Instead the Status column changes from "Printing" to "Printing - Error" and gives me no further indication as to what the problem with. I have tried printing from Notepad on the Apache server, and it prints fine. I've also tried printing to a different printer in PHP, and the same error happens. I am guessing that php_printer.dll is incompatible with Win 2003. I've tried the solution suggested by basurto at canada dot com, and it made no difference. The second parameter appears in the Document Name column of the print queue with no problems in any case. If anyone has a fix or workaround, I would be most grateful!