From: Venkat Raman Don on
Hi,

I did some test on Windows7 as well as Windows Server 2008. I used fastcgi.impersonate=1 in both the cases. On Windows 7 everything is fine. From Windows Server 2008 I am getting below error:

Fatal error: Out of memory (allocated 524288) (tried to allocate 4294967295 bytes) in C:\inetpub\wwwroot\phptest\print.php on line 2

The test file 'print.php' is a simple PHP file where I am making one call to printer_open.

So went and debugged the code. In the function printer_open implementation, we make call to OpenPrinter and later to DocumentProperties. For some reason (I haven't figured it yet), OpenPrinter call is success whereas DocumentProperties fails and returns a negative number. Now look at the code below:

if (OpenPrinter(resource->name, &resource->handle, NULL) != 0) {

resource->pi2 = (PRINTER_INFO_2 *)emalloc(sizeof(PRINTER_INFO_2));

resource->pi2->pDevMode = (DEVMODE *)emalloc(DocumentProperties(NULL, NULL, resource->name, NULL, NULL, 0));

if (DocumentProperties(NULL, resource->handle, resource->name, resource->pi2->pDevMode, NULL, DM_OUT_BUFFER) == IDOK) {

Above the code tries to use Zend allocator to allocate memory assuming DocumentProperties returned a valid value (here the actual size). However DocumentProperties returned a negative value meaning failure and I believe this value is treated as unsigned integer leading to a huge value and thus the above message.

Regarding why DocumentProperties fails, I am not very sure. And this happens on Win2k3 too. Look at the bug reported at http://pecl.php.net/bugs/bug.php?id=12293 long time back.

Keith, you can try accessing the printer under a normal account and which is not part of administrator group and see if this helps. Ensure that the normal user has permission to access the printer.

Thanks,
Don.


-----Original Message-----
From: Keith Davis [mailto:keithdavis(a)pridedallas.com]
Sent: Monday, February 22, 2010 6:14 AM
To: Pierre Joye; Robert
Cc: php-windows(a)lists.php.net
Subject: RE: [PHP-WIN] What about php 5.3 and printers or PHP_PRINTER.DLL ?

Well, I'm on Server 2003, and I still cannot print. It only works with impersonate turned off, and that is not a solution, as I need to connect to remote files.



Keith Davis (214) 906-5183

-----Original Message-----
From: Pierre Joye [mailto:pierre.php(a)gmail.com]
Sent: Monday, February 22, 2010 8:11 AM
To: Robert
Cc: php-windows(a)lists.php.net
Subject: Re: [PHP-WIN] What about php 5.3 and printers or PHP_PRINTER.DLL ?

hi,

It works just fine here, did you install the print server?

Cheers,

On Mon, Feb 22, 2010 at 3:03 PM, Robert <effe.stm(a)virgilio.it> wrote:
> About no chance to print on a shared printer from windows server 2008.
>
> Please note that for some unknown reason, it is either impossible to
> mount a shared printer on windows server 2008. Maybe that errors and
> issues printing from php are connected to this issue.
>
> The only chance we had found to print on a shared printer from windows

> 2008, is to mount the printer as local printer and as port, to give
> the full tcp/ip path + the shared name for the shared printer.
>
> Hope this can help anybody that have the same issue.
>
> Kind regards
>
>
> ""Keith Davis"" <keithdavis(a)pridedallas.com> ha scritto nel messaggio
> news:B0BACCAA54A7CC479FB67D9494FB018A8CC927(a)dc01.pridedallas.com...
> How is that user specified?
>
>
>
> Keith Davis (214) 906-5183
>
> -----Original Message-----
> From: Pierre Joye [mailto:pierre.php(a)gmail.com]
> Sent: Friday, February 05, 2010 3:26 PM
> To: Keith Davis
> Cc: Robert; php-windows(a)lists.php.net
> Subject: Re: [PHP-WIN] What about php 5.3 and printers or
> PHP_PRINTER.DLL ?
>
> On Fri, Feb 5, 2010 at 10:16 PM, Keith Davis
> <keithdavis(a)pridedallas.com> wrote:
>> I found a post that said to set fastcgi.impersonate = 0 to fix this
>> problem. It did.
>>
>> Can someone clarify what that setting does?
>
> It allows a server to run php-cgi under a given user. But that should
> not affect printer at all, except if the user does not have the
> permission to use this printer.
>
> Cheers,
> --
> Pierre
>
> @pierrejoye | http://blog.thepimp.net | http://www.libgd.org
>
> This message (including any attachments) may contain confidential or
> otherwise privileged information and is intended only for the
> individual(s) to which it is addressed. If you are not the named
> addressee you should not disseminate, distribute or copy this e-mail.
> Please notify the sender immediately by e-mail if you have received
> this e-mail by mistake and delete this e-mail from your system. E-mail

> transmission cannot be guaranteed to be secured or error-free as
> information could be intercepted, corrupted, lost, destroyed, arrive
> late or incomplete, or contain viruses. The sender therefore does not
> accept liability for any errors or omissions in the contents of this
message or that arise as a result of e-mail transmission.
> If verification is required please request a hard-copy version from
> the sender.
>
> www.pridedallas.com
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
>
>



--
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org

--
PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php


--
PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


From: Richard Quadling on
On 22 February 2010 22:30, Venkat Raman Don <Don.Raman(a)microsoft.com> wrote:
> DocumentProperties

http://msdn.microsoft.com/en-us/library/dd183576(VS.85).aspx

LONG DocumentProperties(
__in HWND hWnd,
__in HANDLE hPrinter,
__in LPTSTR pDeviceName,
__out PDEVMODE pDevModeOutput,
__in PDEVMODE pDevModeInput,
__in DWORD fMode
);

If the fMode parameter is zero, the return value is the size of the
buffer required to contain the printer driver initialization data.
Note that this buffer can be larger than a DEVMODE structure if the
printer driver appends private data to the structure.

If the function displays the property sheet, the return value is
either IDOK or IDCANCEL, depending on which button the user selects.

If the function does not display the property sheet and is successful,
the return value is IDOK.

If the function fails, the return value is less than zero.

---------------------------------

No indication upon what the failure is from the call to
DocumentProperties, but I wonder if supplying Null for the first 2
parameters is appropriate. The second parameter is probably going to
have to be the handle returned by OpenPrinter.

But this is just me reading the MSDN pages. I'm no expert! Sorry.

Richard.
--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling
From: "Keith Davis" on
Nope. I have an account called Test. It is not an Administrator account
(local or domain) and it can print to \\server05\Auth, but it fails here
too.



Keith Davis (214) 906-5183

-----Original Message-----
From: Venkat Raman Don [mailto:Don.Raman(a)microsoft.com]
Sent: Monday, February 22, 2010 4:30 PM
To: Keith Davis; Pierre Joye; Robert
Cc: php-windows(a)lists.php.net
Subject: RE: [PHP-WIN] What about php 5.3 and printers or
PHP_PRINTER.DLL ?

Hi,

I did some test on Windows7 as well as Windows Server 2008. I used
fastcgi.impersonate=1 in both the cases. On Windows 7 everything is
fine. From Windows Server 2008 I am getting below error:

Fatal error: Out of memory (allocated 524288) (tried to allocate
4294967295 bytes) in C:\inetpub\wwwroot\phptest\print.php on line 2

The test file 'print.php' is a simple PHP file where I am making one
call to printer_open.

So went and debugged the code. In the function printer_open
implementation, we make call to OpenPrinter and later to
DocumentProperties. For some reason (I haven't figured it yet),
OpenPrinter call is success whereas DocumentProperties fails and returns
a negative number. Now look at the code below:

if (OpenPrinter(resource->name, &resource->handle, NULL) != 0) {

resource->pi2 = (PRINTER_INFO_2
*)emalloc(sizeof(PRINTER_INFO_2));

resource->pi2->pDevMode = (DEVMODE
*)emalloc(DocumentProperties(NULL, NULL, resource->name, NULL, NULL,
0));

if (DocumentProperties(NULL, resource->handle,
resource->name, resource->pi2->pDevMode, NULL, DM_OUT_BUFFER) == IDOK) {

Above the code tries to use Zend allocator to allocate memory assuming
DocumentProperties returned a valid value (here the actual size).
However DocumentProperties returned a negative value meaning failure and
I believe this value is treated as unsigned integer leading to a huge
value and thus the above message.

Regarding why DocumentProperties fails, I am not very sure. And this
happens on Win2k3 too. Look at the bug reported at
http://pecl.php.net/bugs/bug.php?id=12293 long time back.

Keith, you can try accessing the printer under a normal account and
which is not part of administrator group and see if this helps. Ensure
that the normal user has permission to access the printer.

Thanks,
Don.


-----Original Message-----
From: Keith Davis [mailto:keithdavis(a)pridedallas.com]
Sent: Monday, February 22, 2010 6:14 AM
To: Pierre Joye; Robert
Cc: php-windows(a)lists.php.net
Subject: RE: [PHP-WIN] What about php 5.3 and printers or
PHP_PRINTER.DLL ?

Well, I'm on Server 2003, and I still cannot print. It only works with
impersonate turned off, and that is not a solution, as I need to connect
to remote files.



Keith Davis (214) 906-5183

-----Original Message-----
From: Pierre Joye [mailto:pierre.php(a)gmail.com]
Sent: Monday, February 22, 2010 8:11 AM
To: Robert
Cc: php-windows(a)lists.php.net
Subject: Re: [PHP-WIN] What about php 5.3 and printers or
PHP_PRINTER.DLL ?

hi,

It works just fine here, did you install the print server?

Cheers,

On Mon, Feb 22, 2010 at 3:03 PM, Robert <effe.stm(a)virgilio.it> wrote:
> About no chance to print on a shared printer from windows server 2008.
>
> Please note that for some unknown reason, it is either impossible to
> mount a shared printer on windows server 2008. Maybe that errors and
> issues printing from php are connected to this issue.
>
> The only chance we had found to print on a shared printer from windows

> 2008, is to mount the printer as local printer and as port, to give
> the full tcp/ip path + the shared name for the shared printer.
>
> Hope this can help anybody that have the same issue.
>
> Kind regards
>
>
> ""Keith Davis"" <keithdavis(a)pridedallas.com> ha scritto nel messaggio
> news:B0BACCAA54A7CC479FB67D9494FB018A8CC927(a)dc01.pridedallas.com...
> How is that user specified?
>
>
>
> Keith Davis (214) 906-5183
>
> -----Original Message-----
> From: Pierre Joye [mailto:pierre.php(a)gmail.com]
> Sent: Friday, February 05, 2010 3:26 PM
> To: Keith Davis
> Cc: Robert; php-windows(a)lists.php.net
> Subject: Re: [PHP-WIN] What about php 5.3 and printers or
> PHP_PRINTER.DLL ?
>
> On Fri, Feb 5, 2010 at 10:16 PM, Keith Davis
> <keithdavis(a)pridedallas.com> wrote:
>> I found a post that said to set fastcgi.impersonate = 0 to fix this
>> problem. It did.
>>
>> Can someone clarify what that setting does?
>
> It allows a server to run php-cgi under a given user. But that should
> not affect printer at all, except if the user does not have the
> permission to use this printer.
>
> Cheers,
> --
> Pierre
>
> @pierrejoye | http://blog.thepimp.net | http://www.libgd.org
>
> This message (including any attachments) may contain confidential or
> otherwise privileged information and is intended only for the
> individual(s) to which it is addressed. If you are not the named
> addressee you should not disseminate, distribute or copy this e-mail.
> Please notify the sender immediately by e-mail if you have received
> this e-mail by mistake and delete this e-mail from your system. E-mail

> transmission cannot be guaranteed to be secured or error-free as
> information could be intercepted, corrupted, lost, destroyed, arrive
> late or incomplete, or contain viruses. The sender therefore does not
> accept liability for any errors or omissions in the contents of this
message or that arise as a result of e-mail transmission.
> If verification is required please request a hard-copy version from
> the sender.
>
> www.pridedallas.com
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
>
>



--
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org

--
PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php


--
PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php


From: Venkat Raman Don on
I already mentioned the reason of failure. It is strange that OpenPrinter function is passing but DocumentProperties is failing. Ideally once OpenPrinter passes, everything should go through. And the worst thing is that this is an abandoned package. I don't see any maintainer for it. Why don't use something else like FPDF or something else which is generally supported?

Thanks,
Don.

-----Original Message-----
From: Keith Davis [mailto:keithdavis(a)pridedallas.com]
Sent: Tuesday, February 23, 2010 5:52 AM
To: Venkat Raman Don; Pierre Joye; Robert
Cc: php-windows(a)lists.php.net
Subject: RE: [PHP-WIN] What about php 5.3 and printers or PHP_PRINTER.DLL ?

Nope. I have an account called Test. It is not an Administrator account
(local or domain) and it can print to \\server05\Auth, but it fails here
too.



Keith Davis (214) 906-5183

-----Original Message-----
From: Venkat Raman Don [mailto:Don.Raman(a)microsoft.com]
Sent: Monday, February 22, 2010 4:30 PM
To: Keith Davis; Pierre Joye; Robert
Cc: php-windows(a)lists.php.net
Subject: RE: [PHP-WIN] What about php 5.3 and printers or
PHP_PRINTER.DLL ?

Hi,

I did some test on Windows7 as well as Windows Server 2008. I used
fastcgi.impersonate=1 in both the cases. On Windows 7 everything is
fine. From Windows Server 2008 I am getting below error:

Fatal error: Out of memory (allocated 524288) (tried to allocate
4294967295 bytes) in C:\inetpub\wwwroot\phptest\print.php on line 2

The test file 'print.php' is a simple PHP file where I am making one
call to printer_open.

So went and debugged the code. In the function printer_open
implementation, we make call to OpenPrinter and later to
DocumentProperties. For some reason (I haven't figured it yet),
OpenPrinter call is success whereas DocumentProperties fails and returns
a negative number. Now look at the code below:

if (OpenPrinter(resource->name, &resource->handle, NULL) != 0) {

resource->pi2 = (PRINTER_INFO_2
*)emalloc(sizeof(PRINTER_INFO_2));

resource->pi2->pDevMode = (DEVMODE
*)emalloc(DocumentProperties(NULL, NULL, resource->name, NULL, NULL,
0));

if (DocumentProperties(NULL, resource->handle,
resource->name, resource->pi2->pDevMode, NULL, DM_OUT_BUFFER) == IDOK) {

Above the code tries to use Zend allocator to allocate memory assuming
DocumentProperties returned a valid value (here the actual size).
However DocumentProperties returned a negative value meaning failure and
I believe this value is treated as unsigned integer leading to a huge
value and thus the above message.

Regarding why DocumentProperties fails, I am not very sure. And this
happens on Win2k3 too. Look at the bug reported at
http://pecl.php.net/bugs/bug.php?id=12293 long time back.

Keith, you can try accessing the printer under a normal account and
which is not part of administrator group and see if this helps. Ensure
that the normal user has permission to access the printer.

Thanks,
Don.


-----Original Message-----
From: Keith Davis [mailto:keithdavis(a)pridedallas.com]
Sent: Monday, February 22, 2010 6:14 AM
To: Pierre Joye; Robert
Cc: php-windows(a)lists.php.net
Subject: RE: [PHP-WIN] What about php 5.3 and printers or
PHP_PRINTER.DLL ?

Well, I'm on Server 2003, and I still cannot print. It only works with
impersonate turned off, and that is not a solution, as I need to connect
to remote files.



Keith Davis (214) 906-5183

-----Original Message-----
From: Pierre Joye [mailto:pierre.php(a)gmail.com]
Sent: Monday, February 22, 2010 8:11 AM
To: Robert
Cc: php-windows(a)lists.php.net
Subject: Re: [PHP-WIN] What about php 5.3 and printers or
PHP_PRINTER.DLL ?

hi,

It works just fine here, did you install the print server?

Cheers,

On Mon, Feb 22, 2010 at 3:03 PM, Robert <effe.stm(a)virgilio.it> wrote:
> About no chance to print on a shared printer from windows server 2008.
>
> Please note that for some unknown reason, it is either impossible to
> mount a shared printer on windows server 2008. Maybe that errors and
> issues printing from php are connected to this issue.
>
> The only chance we had found to print on a shared printer from windows

> 2008, is to mount the printer as local printer and as port, to give
> the full tcp/ip path + the shared name for the shared printer.
>
> Hope this can help anybody that have the same issue.
>
> Kind regards
>
>
> ""Keith Davis"" <keithdavis(a)pridedallas.com> ha scritto nel messaggio
> news:B0BACCAA54A7CC479FB67D9494FB018A8CC927(a)dc01.pridedallas.com...
> How is that user specified?
>
>
>
> Keith Davis (214) 906-5183
>
> -----Original Message-----
> From: Pierre Joye [mailto:pierre.php(a)gmail.com]
> Sent: Friday, February 05, 2010 3:26 PM
> To: Keith Davis
> Cc: Robert; php-windows(a)lists.php.net
> Subject: Re: [PHP-WIN] What about php 5.3 and printers or
> PHP_PRINTER.DLL ?
>
> On Fri, Feb 5, 2010 at 10:16 PM, Keith Davis
> <keithdavis(a)pridedallas.com> wrote:
>> I found a post that said to set fastcgi.impersonate = 0 to fix this
>> problem. It did.
>>
>> Can someone clarify what that setting does?
>
> It allows a server to run php-cgi under a given user. But that should
> not affect printer at all, except if the user does not have the
> permission to use this printer.
>
> Cheers,
> --
> Pierre
>
> @pierrejoye | http://blog.thepimp.net | http://www.libgd.org
>
> This message (including any attachments) may contain confidential or
> otherwise privileged information and is intended only for the
> individual(s) to which it is addressed. If you are not the named
> addressee you should not disseminate, distribute or copy this e-mail.
> Please notify the sender immediately by e-mail if you have received
> this e-mail by mistake and delete this e-mail from your system. E-mail

> transmission cannot be guaranteed to be secured or error-free as
> information could be intercepted, corrupted, lost, destroyed, arrive
> late or incomplete, or contain viruses. The sender therefore does not
> accept liability for any errors or omissions in the contents of this
message or that arise as a result of e-mail transmission.
> If verification is required please request a hard-copy version from
> the sender.
>
> www.pridedallas.com
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
>
>



--
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org

--
PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php


--
PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php



From: Venkat Raman Don on
Richard, I tried that. I passed handle returned by OpenPrinter to DocumentProperties but same result. It's not that function fails for any bad parameter reason. I am getting error number 5 while calling GetLastError() which means some sort of access denied. But then why OpenPrinter is going through I am not able to understand.

Thanks,
Don.

-----Original Message-----
From: Richard Quadling [mailto:rquadling(a)googlemail.com]
Sent: Tuesday, February 23, 2010 1:28 AM
To: Venkat Raman Don
Cc: Keith Davis; Pierre Joye; Robert; php-windows(a)lists.php.net
Subject: Re: [PHP-WIN] What about php 5.3 and printers or PHP_PRINTER.DLL ?

On 22 February 2010 22:30, Venkat Raman Don <Don.Raman(a)microsoft.com> wrote:
> DocumentProperties

http://msdn.microsoft.com/en-us/library/dd183576(VS.85).aspx

LONG DocumentProperties(
__in HWND hWnd,
__in HANDLE hPrinter,
__in LPTSTR pDeviceName,
__out PDEVMODE pDevModeOutput,
__in PDEVMODE pDevModeInput,
__in DWORD fMode
);

If the fMode parameter is zero, the return value is the size of the
buffer required to contain the printer driver initialization data.
Note that this buffer can be larger than a DEVMODE structure if the
printer driver appends private data to the structure.

If the function displays the property sheet, the return value is
either IDOK or IDCANCEL, depending on which button the user selects.

If the function does not display the property sheet and is successful,
the return value is IDOK.

If the function fails, the return value is less than zero.

---------------------------------

No indication upon what the failure is from the call to
DocumentProperties, but I wonder if supplying Null for the first 2
parameters is appropriate. The second parameter is probably going to
have to be the handle returned by OpenPrinter.

But this is just me reading the MSDN pages. I'm no expert! Sorry.

Richard.
--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling