php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26346 Cannot output to a shared printer
Submitted: 2003-11-21 05:30 UTC Modified: 2005-09-26 18:08 UTC
Votes:7
Avg. Score:4.6 ± 0.7
Reproduced:4 of 5 (80.0%)
Same Version:2 (50.0%)
Same OS:1 (25.0%)
From: rich at dwell dot co dot uk Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.3.4 OS: Windows 2003
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rich at dwell dot co dot uk
New email:
PHP Version: OS:

 

 [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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-06 18:29 UTC] basurto at canada dot com
Work around:
------------
I was having the same problem I solve this problem with the following steps:
1. I add Novell client
2. Start nprinter in the machine that have the printer
3. Next I did not add the second parameter It looks like 
your code>>>printer_start_doc($handle, "");
my   code>>>printer_start_doc($handle);
4. voila it works!!
NOTE:
-----
I already have Novell but if you don't have it you can test this in a share printer with Microsoft.
I think there is a problem with the second parameter in a network printer.


I hope this help you.
Regards
 [2004-04-04 17:12 UTC] jasonm at reslife dot org
Don't know if it's a "bug" however....

I have been hearing a lot of talk about people not being able to print to a shared printer with the php_printer.dll extension and functions. I have been doing this for over a year with our churches WAMP checkin system I wrote.  

Everything works fine as long as you are in windows 2000.  When you get to XP, you MUST belong to a domain and the WAMP box MUST be on the domain in order for things to work; therefore you must have some sort of in house domain controller.  Also, all of the drivers for any shared printers MUST be on the WAMP box shared with the same name as the others.

I have deduced that the php_printer.dll relies upon the WAMP box's Print Spooler; shut it down and no printing happens.

With all that said, I must admit our configuration (Windows 2000 Pro, Apache 1.3.27, PHP 4.3.4, MySQL 4.0.13-nt) does seem to crash every Sunday (when there are about 17+ stations running the checkin system and printing; we check in over 800+ unique children in over 4 services).

Could it be that we need to move to Windows 2000 Server Installation? All of the errors/crashes seem to point to a spooler overload (we could potentially have over 10 print jobs being called at any one time..maybe Win2k Pro limit of 10 connections is causing this?)....

Any help or info would be greatly apprecited.  Thanks!
-j
 [2004-07-23 18:11 UTC] pete at downplay dot co dot uk
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!
 [2004-09-24 06:44 UTC] liviu dot dospinescu at rdslink dot ro
There is a problem with php_printer.dll

I have made all the changes in php.ini, but launching Winows XP, there is a "WARNING" mesaj like this:
"Unknown(): Unable to load dynamic library 'C:\php\extensions'(the location of library)  - The specific module could not be found"!
Please, help me!!
I am working under Windows XP Prof. with php4.3.8.
 [2005-01-13 15:08 UTC] esteban_mate at yahoo dot com dot ar
I'm working with php_printer.dll. I install Apache,
php and mysql on XP and i want to print on a shared
printer on another computer (a WIN98), i have the same
drivers in both computers but i get this error when i
try to print to it
Warning: couldn't allocate new printer job on...
Some people said that it's a possible conflict with
permissions.
i look inside the code of php_printer on 
http://home.no.net/wsaebo/php-4.0.6/ext/printer/printer.c
the problem is with startdoc, but i don't know why
Esteban Robles
 [2005-07-29 20:15 UTC] spilon at groupehytech dot com
Hi, I run a basic wamp with windows xp and I can't print on a network printer... BUT I can print with my local printer !!! Later I tried to print with my real web server with the linux server and the same thing happened ! Shit I can't sleep 'until I found the bug. Please can someone help me, I'm in a real pickle.
 [2005-07-29 21:24 UTC] jerry dot martin at gmail dot com
Try installing the network printers as local printers.  You can do so by setting up the port as local.  I did it here at work because I was having the same problems with network printers, but works fine when you setup the printer as local.
 [2005-08-09 22:15 UTC] spilon at groupehytech dot com
I tried this, but i can't change my printer port, even if I install the drivers locally... If I use the printer_write() function, I can see text , but the thing is, I would like to print with a preset page setup.
 [2005-09-23 15:31 UTC] sniper@php.net
Report this to the pecl bug system: http://pecl.php.net/bugs/
 [2005-09-26 11:30 UTC] rich at dwell dot co dot uk
As a workaround, I've found that I can print from a shared printer using the cli version of PHP. Go figure. 

I've bundled any printing routines into a separate script and then use shell_exec() to call the CLI version of PHP to run this script.

What a kludge.
 [2005-09-26 18:08 UTC] sniper@php.net
Yes, the extension itself is also a kludge.
Now be nice and report any remaining issues to the PECL bug system.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jun 08 07:01:27 2025 UTC