Application - Web. Generates checks on the server. The task is to send a document to print from the application using PHP, poisoning the document to a shared printer - IP: port.

You should not write answers about what to print using JAVA. This particular question interests you!

Seen working examples. It is impossible to implement something like this. Coping in the direction of the PECL extension for PHP - printer. Printer functions are described in the PHP documentation.

But at the office. PECL does not have this extension for download. Those that found on the Internet can not be installed on the home server. (PHP 5.3.3, Win 7 axis). On the working application Centos 6.6 is used.

  • It all depends on the printer or print server, and also on what you want to print. I would form a pdf and send it to the ftp-print - this is the easiest way, but it would be possible to raise the print using IPP - tutankhamun
  • The fact is that printers can be different. On this depends on the method of implementation? - L. Aleksandr
  • Of course. If you plan to use a zoo of printers, I recommend that you instruct CUPS to deal with drivers and transcoding between formats, and she is already fed files in a convenient format for building on the PHP side (depending on the tasks, I would choose between a PNG or JPEG raster or a vector PDF, SVG or even HTML) - tutankhamun

1 answer 1

On Centos try installing lp .

And then with the help of system calls you can delegate all the work to this utility:

exec('/usr/bin/lp -d myprinter -o scaling=200 %filename%', $output, $status); 
  • As far as I understand that CUPS is an analogue of lp? There is no experience when working not with CUPS, not lp .. As far as I understand CUPS is a little easier to understand? - L. Aleksandr
  • not really. cups is a print server. Installing cups you will have a web interface on the local host + a bunch of dependencies, with which you can manage printers, send to print and so on. It has an API that can be used for your purposes, but it is much more cumbersome - mkardakov
  • Sorry for possibly stupid questions, can a web application written in php + java call system calls for lp? How to implement it? Please write the simplest example - L. Aleksandr
  • I wrote in the answer. php.net/manual/en/book.exec.php php will execute an external program (which must first be installed on your OS). Analogs of course should be in Java. The main thing to remember is that, as a rule, a web application is launched on behalf of another user (apache, www-data), therefore, the rights for your external program must be configured accordingly - mkardakov