Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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?
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.
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.
Thank you.
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.
PHP runs on the server, so for PHP is is also the same printer.
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.
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.
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
Last edited by adeeriswan; 12-06-2009 at 11:39 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.