phpprintinglpr

php LPR Printer class


How do I use LPR Printer class to print the txt file with USB printer EPSON LQ-1150?

<?php 
include("PrintSend.php");
include("PrintSendLPR.php");

$lpr = new PrintSendLPR(); 
$lpr->set-host("192.168.1.152"); //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.
?>

In that set Host we want to use Share printer Name or host?


Solution

  • This is the command I am using for printing IP printers:

    You need to install lpr service for windows and linux on the server.

    if ($this->agent->platform() == 'Linux') {
                $command = 'lpr -S ' . $printer->printer_ip . ' -P ' . $printer->printer_name . ' -o -x ' . $file;
                //$command = 'lp -d ' . $printer->printer_name . ' ' . $file;
                if (exec($command)) {
    
                    return TRUE;
                } 
                else {
                    return FALSE;
                }
            }
            if ($this->agent->platform() == 'Windows XP') {
    
                $command = 'lpr -S ' . $printer->printer_ip . ' -P ' . $printer->printer_name . ' -o -x ' . $file;
    
                if (exec($command)) {
                    return TRUE;
                } 
                else {
                    return FALSE;
                }
            }
    
            if ($this->agent->platform() == 'Unknown Windows OS') {
    
                $command = 'lpr -S ' . $printer->printer_ip . ' -P ' . $printer->printer_name . ' -o -x -d ' . $file;
    
                if (exec($command)) {
                    return TRUE;
                } 
                else {
                    return FALSE;
                }
            }