PHP: print directly from php script
Hi all, I didn't want bother you but I'm in trouble... deep in trouble. I "must" create a function, in my php application, to allow continuos print. I mean that it should send to printer "directly" some letters (changing names and addresses ;-) of course). I used javascript function "window.print()" but it wait for a button pressed from the
user... Can anybody help me ? Thanks. |
Do you mean the client has to have a print function? The one who is browsing? Since you are using Javascript, this runs only client side.
The print function without acknowledge has intentionally been left out of clients to make sure the web designer would not be able to print tons of paper for his fun, therefor a user acknowledge is always needed. But you are talking about PHP application. Do you mean you have to print on the server side? jlinkels |
Well, I wrote an application: I mean that the server is not "an internet" server: it's in the same room where clients are. In this case server's printer is THE client's printer (that printer is shared through the network).
|
That doesn't answer the question. Does the client print (Internet Explorer, Mozilla) or does the server print (Apache)? Regardless of where the printer is, regardless to what is is attached.
I have the idea that it is the client which prints, but if it is the client, how could PHP help you. PHP puts together the web page for you, and can do a zillion other things, but always on the server. jlinkels |
Thank you.
Now I can see that my question was wrong. Maybe the right question could be: How can I ask to PHP to print on default printer of the server? In my case it's ok, because the server's printer is the printer (the only one) that anybody can use. From network point of view it's always the same printer, but I understand that from php point of view it's not the same. Regards. |
Quote:
Is it a Windows platform which runs the server? Then look at the print_open and print_write functions. For Linux it is more difficult. Almost as difficult as creating a graph or a PDF file. I would recommend to open a temporary file, put the print data in there, and use an exec call to send it to lp. To get rid of the temporary file, call a cleanup function every time the web page is entered, which deletes all temporary files older than 5 minutes. http://www.linuxquestions.org/questi...nd#post3415608 jlinkels |
Your PHP script will need to create printable pages first, most often in PostScript or PDF format. Libharu is pdf development library that you could use to create a CGI application for the task of creating a printable document. Pslib does the same for PostScript. PostScript is old, but has the advantage that it is for the larger part human-readable.
Your PHP script can either create PS/PDF files directly or call some other custom CGI application via a 'system' call, and then feed that document to the printer with a system call to 'lp' (see http://www.faqs.org/docs/Linux-HOWTO...age-HOWTO.html). Printing will be done on any of the printers that are available to the server. Debian |
Does this problem solved?
@Zelrond : Does this problem solved?
I'm also have this problems. I was to created a simple queue app, just for locally (LAN) so the server need to print a receipt (which contains the queue number) directly.. @jlinkels : if you don't mind, would u show us an example of it? I'm really a newbie on PHP (i used to VB). Thanx brother, I'll appreciate ur help |
All times are GMT -5. The time now is 10:38 PM. |