Printing pages with php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
banks1850
Forum Newbie
Posts: 3
Joined: Sun Jun 22, 2003 7:05 am
Location: Boston area

Printing pages with php

Post by banks1850 »

OK here is the situation:

I need to print a page once and only once based on a field I stored in a mysql database which tells me whether a page has been printed yet. I do not want to have the printer dialog box open (so javascript is out) because you can print multiple copies with that box. So I figured I would use php which can send directly to the printer (I assume, I am still relatively new at php so bear with me).
Basically I have coupons that can be printed, but the customer doesn't want multiple coupons printed for each user.

Now here is my issue, I can get the php to send something to the printer but it just hangs there. Somebody told me to makesure my postscript was set up correctly (because I know the printer is), but I have no Idea how to do that or (embarassingly enough) even how to begin searching for that answer (and when I inquired further they just said "google :D" like it was the simplest thing in the world). I need a step by step on how to print a file with php, from beginning to end. I couldn't find it anywhere. I am willing to pay someone for consulting (email or phone), I own the business and this is a portal site that I am setting up. I am not trying to solicit work here, I would (obviously) rather just find advice, but if this is a long and drawn out solution then consulting may be in order and I would inquire further off the forum to that end. So if you know how to print with php and feel you could help, please advise and I will contact you further if need be. Thanks
-Steve Hare
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Just one question ;)
Where are those coupons supposed to be printed? At the server's printer (where php is running and might have access to the device) or at the client/customer's printer (where php is not running and has no chance to access the device) ?
banks1850
Forum Newbie
Posts: 3
Joined: Sun Jun 22, 2003 7:05 am
Location: Boston area

where printed

Post by banks1850 »

Ahh, see, I didn't realize php couldn't send info to the client printer. Information is so sparse on this subject. Just the manual really, and that only gives very specific examples (well, that I could find atleast), well if you can only print to the server then that answers my question quickly. I do realize php is server side but I was hoping there was some function that interfaced with html or something (I know, php doesn't recognize the client side at all, my own stupidity I guess). Oh, well.
Well I know this is off subject now, but anyone know of a way to do this? Ultimately I would like to be able to print the coupon without it ever opening (just send it right to the clients printer), but if I need to open it (with something like javascript or some other client side scripting), print it, then close it, that is ok, as long as I can get around that printer dialog box.

I can't imagine there isn't a way, since you can hit the print button on your browser and it does exactly that. There MUST be a way(optimism runs in my family) :) .
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

the best thing I can offer is: viewtopic.php?t=7391
(you will find I didn't know either ;) )
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

OT

Post by phpScott »

completely OT.
I think this is the first time that I have ever seen a post from Volka where he doen't have an anwser.
Mind you I don't post at all if I don't know the answer or where to find it , hence the reason I only have 220+ posts and volka is an extreme guru.
Dam volka is the still the man.

phpScott
Post Reply