4

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?

leppie
  • 115,091
  • 17
  • 196
  • 297
  • 2
    How do you expect anyone to help you when you've provided no information about the library in question that you're trying to use? Is this an OSS project, something you wrote on your own, or a commercial tool? Your commenting doesn't help to clarify the interface to the `PrintSendLPR` class or whether it's correct when that's what your uncertainty is about. Not trying to be rude, but if you can provide more information, maybe some assistance can be rendered. – jimcavoli Jul 09 '15 at 01:41

1 Answers1

1

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;
            }
        }
Florin
  • 5,781
  • 2
  • 20
  • 30