I can’t really find a topic on how to print a file with the printer.
First off, I dont’t mean print like echo, but a real printer.
I want to have the user click on a button, and than it starts printing the page.
The same as javascript:window.print() does, but than with PHP. Is there such option?
Thanks!
Do you mean printing on server-side or client side?
For client-side you can include a javascript snippet which calls the JS function you mentioned:
For server-side: it is definitely more complicated. You could either find a PHP interface, e.g. to CUPS (the standard UNIX printing system) or call a system program that prints the document. Svish posted a link to
a CUPS interface as far as I seean interface to printing in MS Windows (useful only if the server is running under Windows, of course).Edit: If you expect to find a solution which prints the page PHP outputs rendered by the client browser and but not printed on the client, but on the server — this should be impossible. I guess you could implement sending the output of PHP the a system program that renders the page itself but it will never look 100% like on the client. Maybe it’s acceptable to call a printing program on the server, pass all necessary information to it and it renders some document of its own, e.g. an RTF text file?