4

如何使用 LPR Printer 类txt使用 USB 打印机 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.
?>

在该组主机中,我们要使用共享打印机名称或主机?

4

1 回答 1

1

这是我用于打印 IP 打印机的命令:

您需要在服务器上安装适用于 windows 和 linux 的 lpr 服务。

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;
            }
        }
于 2015-07-09T17:58:04.010 回答