I wish to be able to allow a user after clicking a button print out a formated html page. Basically a membership form. I know the browser has a print function but I would like to control the look of the document. An online form has been rejected by the committee thus far. Still waiting for approval.
So how does one open up a clients printer functions for them to print.
Terry
Well, JavaScript’s print() function opens the regular print dialog. By using a print-stylesheet you can control the output of the page to a great extent, but you’ll still not have full control (e.g. over the headers and footers the browsers add).
From PHP you simply cannot address a client’s printer, if you believe it or not. You could access a printer attached to the server (though that’ll be tricky) and print there, but then the clients will all need to visit your datacentre to pick up what they’ve printed.
Well you’d better because you’re going to be disappointed otherwise. As Immerse has said you can prompt the browser to display the print dialog but its down to the user to actually hit the print button. There is no way that you can do this in php which is a SERVER SIDE language. PHP does not run on the browser so not only do you have the javascript limitation to over come you also have the php only running on the server issue to.
Of course, if you do find a way which doesn’t involve forcing the user to install php, please do let us know as you’ll of made many other programmers very happy.
What you could look into however (but again this depends on the user agreeing to install and run it) is using either ActiveX or a java applet.
To round this off there is no 100% guaranteed method for communicating with the users printer (or that they even have a printer).
I obviously am under a misconception. I will take on board the javascript possibility. Thanks for the comments. I will see what works best. I could let the prospective member download a formated document which may be the easiest option. I definatly will not knock myself out over it. Actually opening a print dialog is what I am after so that is a way to go also. It would be up to the client to decide to print or no.
Anyway thanks again for helping me not bark up the wrong tree