Search code examples
phplinuxprintingcupsnetwork-printers

printing over network from PHP app


I have a set of printers connect over a network with Static IP assigned to each printer.

Now i have a PHP web application running on a linux server which needs to send print jobs, to these printer over the network.

Is this possible using lpr or cups and how do i go about it.


Solution

  • You could use the LPR Printer class from here:

    http://www.phpclasses.org/package/2540-PHP-Abstraction-for-printing-documents.html

    Example:

    <?php 
    include("PrintSend.php");
    include("PrintSendLPR.php");
    
    $lpr = new PrintSendLPR(); 
    $lpr->setHost("10.0.0.17"); //Put your printer IP here 
    $lpr->setData("C:\\wampp2\\htdocs\\print\\test.txt"); //Path to file, OR string to print. 
    
    $lpr->printJob("someQueue"); //If your printer has a built-in printserver, it might just accept anything as a queue name.
    ?>