php-windows Digest 27 Oct 2005 04:02:46 -0000 Issue 2805

Topics (messages 26433 through 26438):

Re: Mysql support in PHP 5.0.5
        26433 by: Rosty Kerei
        26438 by: S. Kang

Re: [PHP] PDF printing under windows.
        26434 by: tg-php.gryffyndevelopment.com
        26435 by: Finner, Doug
        26436 by: tg-php.gryffyndevelopment.com
        26437 by: tg-php.gryffyndevelopment.com

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Make sure you have correct extension_dir value in your php.ini

Sincerely,
Rosty Kerei
[EMAIL PROTECTED]

""Beau Newcomb"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I've tried everything the faqs say and I'm still unable to get mysql 
> support
> in PHP5..
>
>
>
> I've added H:\php to my Windows PATH variable (H: is my main drive)
>
> I've uncommented php_mysql.dll
>
> I've added the extension directory to php.ini
>
> Rebooted the server
>
>
>
> Before doing the above, phpinfo had absolutely no instances of mysql in 
> it,
> showing it neither disable or enabled. After doing the above, phpinfo does
> show mysql added to environment paths, but still no table showing whether
> it's enabled or disabled.
>
>
>
> Am I missing something?  One faq says not to use mysql.dll but mysqli.dll 
> ??
> where is this?  Can anyone shed some light on this subject for me?
>
>
>
> When I run a mysql test script php returns an error in the line with
> mysql_connect saying it doesn't understand the function.  (which tells me
> mysql support isn't working)
>
>
>
> 

--- End Message ---
--- Begin Message --- if you are using Apache Web server, you don't have to put in windows system directory.

You can put php.ini and libMySQL.dll in your apache bin directory. eg. c:\apache\bin\php.ini libMySQL.dll. If you don't copy libMySQL.dll to bin directory. Apache can't load your Mysql DLL (php_mysql.dll).

BTW, libMySQL.dll is located in your mysql directory. eg. c:\mysql\bin\libMySQL.dll

uncomment php_mysql.dll in your php.ini (c:\apache\bin\php.ini)

:)

Beau Newcomb wrote:

I've tried everything the faqs say and I'm still unable to get mysql support
in PHP5..

I've added H:\php to my Windows PATH variable (H: is my main drive)

I've uncommented php_mysql.dll

I've added the extension directory to php.ini

Rebooted the server

Before doing the above, phpinfo had absolutely no instances of mysql in it,
showing it neither disable or enabled. After doing the above, phpinfo does
show mysql added to environment paths, but still no table showing whether
it's enabled or disabled.
Am I missing something?  One faq says not to use mysql.dll but mysqli.dll ??
where is this?  Can anyone shed some light on this subject for me?

When I run a mysql test script php returns an error in the line with
mysql_connect saying it doesn't understand the function.  (which tells me
mysql support isn't working)


--- End Message ---
--- Begin Message ---
Two (and a half) things:

1. Even though DOS/Windows machines don't have, specifically, /dev/printer or 
/dev/lpr or whatever the *nix specific is, it does have a LPTx: device

According to the page listed below, it may be possible to do:
copy /b filename LPTx

The /b indicates it's a binary file.  How it'd handle PDF fonts and such, I'm 
not sure, but I know that some printers can decode PDF's internally so that'd 
work out great.

2. Second point... If all you need is a simple print function and you have 
exec() privs, why not try to find a DOS based printing solution.  The copy 
command above was mentioned on this page:
http://www.lerup.com/printfile/

It says it works with Windows 3.1 to XP.  And it even works with command line 
options:

"PrintFile also works well with command line (DOS) programs. It has several 
command line options and can read data from command line standard input, e.g. a 
command line pipe. A command like:
dir | prfile32"

So I guess it sets up it's own print device that you can pipe to.

And finally... the half a point.  All of this may not be necessary because you 
can configure Windows printers to support DOS (although I havn't done this in 
ages, I assume you still can in XP) so in theory the normal DOS "print" command 
would pipe through Windows drivers and print handling to the printer of choice.


So in general, there's probably zero need to use COM to print.  One of these 
options should pipe the file through Windows which in turn, could possibly send 
it through the proper printing method.   If not, you might be able to look in 
your registry and find the right-click "Print..." option and see if it's 
something you can execute from command line.

Ok, I know this email's too long already, but I know someone's going to say 
"How do you do that?"  So here's the 50 cent tour:

1. Pull up "regedit"
2. Search for the file extension ".pdf"
3. Make note of the "(Default)" value, in this case "AcroExch.Document" (I 
think this is specific to having the full Acrobat installed)
3. Below the area where all the file extensions are in HKEY_CLASSES_ROOT there 
are the actual named app section (that way, ".gif" and ".jpg" can both point to 
Photoshop.document" or something.. get it?)  So search for "AcroExch.Document" 
in this case
4. Expand that tree and look for "shell". These are all the things that show up 
on your right-click menu.  In this case, we have a "print" section. Under each 
of these entries, there should be (but sometimes not) a "command" branch.  This 
is what's run when you select that option from the right-click menu.  And 
voila! We find that the command to use Acrobat to print (which can be executed 
from command line on a Windows machine) is:
"C:\Program Files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe" /p /h "%1"

Substituting the %1 for the filename.


Using that command line in a php exec() call should exactly simulate selecting 
right-click PRINT on a PDF file.


Crossposting this to PHP-Win for their benefit too since this is more Windows 
related than PHP General.

I see lots of ways to potentially solve this problem without using COM.

I loved messing with COM (with or without PHP) for a while, but it's not a 
great general solution to things unless you absolutely HAVE to control the app 
(which is very cool and slick sometimes, but not for something as simple as 
printing).

Hope this gives you some new avenues to persue.  Best of luck!

-TG

= = = Original message = = =

Richard Lynch wrote:

>On Mon, October 24, 2005 1:48 pm, Dave Lists wrote:
>  
>
>>I'm generating PDFs under windows using PDFlib and all is easy. What I
>>am wondering though, and google reveals nothing usefull, can I print
>>the
>>PDF to a network printer from windows? I'm presuming to print the file
>>I
>>would ahve to use COM and open it under Acrobat? Anyone done this
>>before
>>and have any pointers? I'm printing out invoices and what to automate
>>the task.
>>    
>>
>
>If, for some weird reason, you want to allow the user (authenticated,
>logged in, trusted) to print to a networked computer on the WEB
>SERVER, then your best bet is probably to figure out how to print that
>PDF from MS-DOS and then to use http://php.net/exec to print it, I
>would guess...
>  
>
 It's from a cli PHP install on a local machine :-)

>You might be able to use PHP to open up a COM object to convince
>Adobe/Windows/whatever to print...
>  
>
 COM makes me want to cry ;-) At the moment I'm trying to convince 
OpenOffiice it wants to play with PHP and COM.
 I have tried to exec print on the windows box but that just hung.

>If it was a Un*x server, you'd just send the document to lpr or CUPS
>or something, and be done with it, probably in a half-hour of work,
>even allowing for a protracted battle with file/exec permissions.
>
>  
>
I'm not sure I could just fire a PDF at lpr, but no doubt it would be 
much easier under Unix :-)

Dave.


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

--- End Message ---
--- Begin Message ---
Not sure how this might work in PHP, but there is something called WSH
(go to MS and poke around) that gives you access to a ton of really
interesting Windows bits and pieces.  The following is a script I run in
Lotus Notes (LotusScript is rather like VBA) and it allows you to set
the default printer to something which you then just print to and reset
the default to whatever it was.  PDFCreator is a 'printer' that
generates PDF files (you probably don't want this since use of
PDFCreator includes it's own set of user interactions but the WSH
concept may still work).

Warning - I'm not a WSH expert and I never figured out how to properly
reset the printer to the user's default so I don't actually use this
script.  Still, someone smarter than me may have the magic touch - give
it a whirl.


Sub Initialize
     Dim net
     pName$ = "PDFCreator"
     Set net = CreateObject("WScript.Network")    
     net.SetDefaultPrinter pName$
     
End Sub 

Doug

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 25, 2005 10:50 AM
To: [email protected]; [email protected]
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] PDF printing under windows.

Two (and a half) things:

1. Even though DOS/Windows machines don't have, specifically,
/dev/printer or /dev/lpr or whatever the *nix specific is, it does have
a LPTx: device

According to the page listed below, it may be possible to do:
copy /b filename LPTx

The /b indicates it's a binary file.  How it'd handle PDF fonts and
such, I'm not sure, but I know that some printers can decode PDF's
internally so that'd work out great.

2. Second point... If all you need is a simple print function and you
have exec() privs, why not try to find a DOS based printing solution.
The copy command above was mentioned on this page:
http://www.lerup.com/printfile/

It says it works with Windows 3.1 to XP.  And it even works with command
line options:

"PrintFile also works well with command line (DOS) programs. It has
several command line options and can read data from command line
standard input, e.g. a command line pipe. A command like:
dir | prfile32"

So I guess it sets up it's own print device that you can pipe to.

And finally... the half a point.  All of this may not be necessary
because you can configure Windows printers to support DOS (although I
havn't done this in ages, I assume you still can in XP) so in theory the
normal DOS "print" command would pipe through Windows drivers and print
handling to the printer of choice.


So in general, there's probably zero need to use COM to print.  One of
these options should pipe the file through Windows which in turn, could
possibly send it through the proper printing method.   If not, you might
be able to look in your registry and find the right-click "Print..."
option and see if it's something you can execute from command line.

Ok, I know this email's too long already, but I know someone's going to
say "How do you do that?"  So here's the 50 cent tour:

1. Pull up "regedit"
2. Search for the file extension ".pdf"
3. Make note of the "(Default)" value, in this case "AcroExch.Document"
(I think this is specific to having the full Acrobat installed) 3. Below
the area where all the file extensions are in HKEY_CLASSES_ROOT there
are the actual named app section (that way, ".gif" and ".jpg" can both
point to Photoshop.document" or something.. get it?)  So search for
"AcroExch.Document" in this case 4. Expand that tree and look for
"shell". These are all the things that show up on your right-click menu.
In this case, we have a "print" section. Under each of these entries,
there should be (but sometimes not) a "command" branch.  This is what's
run when you select that option from the right-click menu.  And voila!
We find that the command to use Acrobat to print (which can be executed
from command line on a Windows machine) is:
"C:\Program Files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe" /p /h "%1"

Substituting the %1 for the filename.


Using that command line in a php exec() call should exactly simulate
selecting right-click PRINT on a PDF file.


Crossposting this to PHP-Win for their benefit too since this is more
Windows related than PHP General.

I see lots of ways to potentially solve this problem without using COM.

I loved messing with COM (with or without PHP) for a while, but it's not
a great general solution to things unless you absolutely HAVE to control
the app (which is very cool and slick sometimes, but not for something
as simple as printing).

Hope this gives you some new avenues to persue.  Best of luck!

-TG

= = = Original message = = =

Richard Lynch wrote:

>On Mon, October 24, 2005 1:48 pm, Dave Lists wrote:
>  
>
>>I'm generating PDFs under windows using PDFlib and all is easy. What I

>>am wondering though, and google reveals nothing usefull, can I print 
>>the PDF to a network printer from windows? I'm presuming to print the 
>>file I would ahve to use COM and open it under Acrobat? Anyone done 
>>this before and have any pointers? I'm printing out invoices and what 
>>to automate the task.
>>    
>>
>
>If, for some weird reason, you want to allow the user (authenticated, 
>logged in, trusted) to print to a networked computer on the WEB SERVER,

>then your best bet is probably to figure out how to print that PDF from

>MS-DOS and then to use http://php.net/exec to print it, I would 
>guess...
>  
>
 It's from a cli PHP install on a local machine :-)

>You might be able to use PHP to open up a COM object to convince 
>Adobe/Windows/whatever to print...
>  
>
 COM makes me want to cry ;-) At the moment I'm trying to convince
OpenOffiice it wants to play with PHP and COM.
 I have tried to exec print on the windows box but that just hung.

>If it was a Un*x server, you'd just send the document to lpr or CUPS or

>something, and be done with it, probably in a half-hour of work, even 
>allowing for a protracted battle with file/exec permissions.
>
>  
>
I'm not sure I could just fire a PDF at lpr, but no doubt it would be
much easier under Unix :-)

Dave.


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
_______________________________________________________________________
This e-mail message has been sent by Kollsman, Inc. and is for the use
of the intended recipients only. The message may contain privileged
or confidential information. If you are not the intended recipient
you are hereby notified that any use, distribution or copying of
this communication is strictly prohibited, and you are requested to
delete the e-mail and any attachments and notify the sender immediately.

--- End Message ---
--- Begin Message ---
David.. I think I accidentally deleted your last message, but I believe you 
said something about Acrobat not closing after it gets done printing.  Here are 
a few thoughts:

1. If you right click on something and select "print" and it performs the 
command line action listed in the registry as mentioned below, it SHOULD exit 
when done printing. If it doesn't, it could be an app issue.

2. If you use COM and app doesn't close properly, you might want to look at the 
app "Close" as well as "Quit" methods.  If I recall, you can do one, or the 
other, but an instance of the app may still hover invisible in the background.  
I remember using both (in a certain order.. reversing the order made it so the 
app still stayed loaded.. the correct order though made sure the app closed 
properly).

3. If a certain file type (like say Excel files for instance) requires a 
specific app to interpret it's data for output, then you kind of can't get 
around loading the app in order to print it.  Unless you can find a smaller 
view/print-only app that's made for handling that app's data files.   In the 
case of PDF, if you're lucky then your printer knows how to decode them and you 
might get away with piping the raw binary file directly to the print device 
(LPTx in the case of DOS/Windows.. where "x" is of course the number of the 
printer device.  Might have to mount the printer to that port though or do the 
DOS printer config in Windows).   The printer needs intelligible data from the 
PC if it doesn't natively know how to handle the file.  So again, you need the 
real app or a reader type app to load in order to send the printer proper data.


If you get the print command line out of the registry as listed below, then it 
SHOULD exit properly.  If not, it's a problem with the app and not with your 
code.  Try performing the CLI command in a command prompt and see if the app 
exits properly before doing it in PHP.    Something as common (and an open 
standard) like PDF, you should be able to find other DOS and/or Windows apps 
that'll print it, but you'll probably still have to use the command line and 
exec() call of some kind, unless you use COM which is overly complicated and 
burdensome in my opinion.

-TG

= = = Original message = = =

Two (and a half) things:

1. Even though DOS/Windows machines don't have, specifically, /dev/printer or 
/dev/lpr or whatever the *nix specific is, it does have a LPTx: device

According to the page listed below, it may be possible to do:
copy /b filename LPTx

The /b indicates it's a binary file.  How it'd handle PDF fonts and such, I'm 
not sure, but I know that some printers can decode PDF's internally so that'd 
work out great.

2. Second point... If all you need is a simple print function and you have 
exec() privs, why not try to find a DOS based printing solution.  The copy 
command above was mentioned on this page:
http://www.lerup.com/printfile/

It says it works with Windows 3.1 to XP.  And it even works with command line 
options:

"PrintFile also works well with command line (DOS) programs. It has several 
command line options and can read data from command line standard input, e.g. a 
command line pipe. A command like:
dir | prfile32"

So I guess it sets up it's own print device that you can pipe to.

And finally... the half a point.  All of this may not be necessary because you 
can configure Windows printers to support DOS (although I havn't done this in 
ages, I assume you still can in XP) so in theory the normal DOS "print" command 
would pipe through Windows drivers and print handling to the printer of choice.


So in general, there's probably zero need to use COM to print.  One of these 
options should pipe the file through Windows which in turn, could possibly send 
it through the proper printing method.   If not, you might be able to look in 
your registry and find the right-click "Print..." option and see if it's 
something you can execute from command line.

Ok, I know this email's too long already, but I know someone's going to say 
"How do you do that?"  So here's the 50 cent tour:

1. Pull up "regedit"
2. Search for the file extension ".pdf"
3. Make note of the "(Default)" value, in this case "AcroExch.Document" (I 
think this is specific to having the full Acrobat installed)
3. Below the area where all the file extensions are in HKEY_CLASSES_ROOT there 
are the actual named app section (that way, ".gif" and ".jpg" can both point to 
Photoshop.document" or something.. get it?)  So search for "AcroExch.Document" 
in this case
4. Expand that tree and look for "shell". These are all the things that show up 
on your right-click menu.  In this case, we have a "print" section. Under each 
of these entries, there should be (but sometimes not) a "command" branch.  This 
is what's run when you select that option from the right-click menu.  And 
voila! We find that the command to use Acrobat to print (which can be executed 
from command line on a Windows machine) is:
"C:\Program Files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe" /p /h "%1"

Substituting the %1 for the filename.


Using that command line in a php exec() call should exactly simulate selecting 
right-click PRINT on a PDF file.


Crossposting this to PHP-Win for their benefit too since this is more Windows 
related than PHP General.

I see lots of ways to potentially solve this problem without using COM.

I loved messing with COM (with or without PHP) for a while, but it's not a 
great general solution to things unless you absolutely HAVE to control the app 
(which is very cool and slick sometimes, but not for something as simple as 
printing).

Hope this gives you some new avenues to persue.  Best of luck!

-TG

= = = Original message = = =

Richard Lynch wrote:

>On Mon, October 24, 2005 1:48 pm, Dave Lists wrote:
>  
>
>>I'm generating PDFs under windows using PDFlib and all is easy. What I
>>am wondering though, and google reveals nothing usefull, can I print
>>the
>>PDF to a network printer from windows? I'm presuming to print the file
>>I
>>would ahve to use COM and open it under Acrobat? Anyone done this
>>before
>>and have any pointers? I'm printing out invoices and what to automate
>>the task.
>>    
>>
>
>If, for some weird reason, you want to allow the user (authenticated,
>logged in, trusted) to print to a networked computer on the WEB
>SERVER, then your best bet is probably to figure out how to print that
>PDF from MS-DOS and then to use http://php.net/exec to print it, I
>would guess...
>  
>
 It's from a cli PHP install on a local machine :-)

>You might be able to use PHP to open up a COM object to convince
>Adobe/Windows/whatever to print...
>  
>
 COM makes me want to cry ;-) At the moment I'm trying to convince 
OpenOffiice it wants to play with PHP and COM.
 I have tried to exec print on the windows box but that just hung.

>If it was a Un*x server, you'd just send the document to lpr or CUPS
>or something, and be done with it, probably in a half-hour of work,
>even allowing for a protracted battle with file/exec permissions.
>
>  
>
I'm not sure I could just fire a PDF at lpr, but no doubt it would be 
much easier under Unix :-)

Dave.



___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

--- End Message ---
--- Begin Message ---
This is really dumb and overly simple, which is probably why it was missed/not 
brought up, but it just occurred to me that, assuming you have a browser-based 
interface to your app, why don't you just send the PDF to the browser for 
printing?  Then it should use the Acrobat Reader plugin to open the app then 
just have the user (you?) click the print button?  Or do you want it totally 
one-button click and that's it?

Just a thought. 

-TG

= = = Original message = = =

Richard Lynch wrote:

>On Mon, October 24, 2005 1:48 pm, Dave Lists wrote:
>  
>
>>I'm generating PDFs under windows using PDFlib and all is easy. What I
>>am wondering though, and google reveals nothing usefull, can I print
>>the
>>PDF to a network printer from windows? I'm presuming to print the file
>>I
>>would ahve to use COM and open it under Acrobat? Anyone done this
>>before
>>and have any pointers? I'm printing out invoices and what to automate
>>the task.
>>    
>>
>
>If, for some weird reason, you want to allow the user (authenticated,
>logged in, trusted) to print to a networked computer on the WEB
>SERVER, then your best bet is probably to figure out how to print that
>PDF from MS-DOS and then to use http://php.net/exec to print it, I
>would guess...
>  
>
 It's from a cli PHP install on a local machine :-)

>You might be able to use PHP to open up a COM object to convince
>Adobe/Windows/whatever to print...
>  
>
 COM makes me want to cry ;-) At the moment I'm trying to convince 
OpenOffiice it wants to play with PHP and COM.
 I have tried to exec print on the windows box but that just hung.

>If it was a Un*x server, you'd just send the document to lpr or CUPS
>or something, and be done with it, probably in a half-hour of work,
>even allowing for a protracted battle with file/exec permissions.
>
>  
>
I'm not sure I could just fire a PDF at lpr, but no doubt it would be 
much easier under Unix :-)

Dave.


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

--- End Message ---

Reply via email to