【问题标题】:php LPR Printer classphp LPR 打印机类
【发布时间】:2015-07-22 23:00:26
【问题描述】:

如何使用 LPR 打印机类通过 USB 打印机 EPSON LQ-1150 打印 txt 文件?

<?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.
?>

在我们想要使用共享打印机名称或主机的那组主机中?

【问题讨论】:

  • 当您没有提供有关您尝试使用的相关库的信息时,您希望其他人如何帮助您?这是一个 OSS 项目,你自己写的东西,还是一个商业工具?您的评论无助于澄清PrintSendLPR 类的接口,或者当您不确定时它是否正确。无意粗鲁,但如果您能提供更多信息,也许可以提供一些帮助。

标签: php printing lpr


【解决方案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;
            }
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-07
    • 1970-01-01
    • 2015-07-18
    • 2018-03-03
    • 1970-01-01
    • 1970-01-01
    • 2013-11-26
    • 1970-01-01
    相关资源
    最近更新 更多