2015-05-12 60 views
4

如何使用LPR打印機類打印txt文件用USB打印機EPSON LQ-1150?PHP LPR打印機類

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

在那個集合中我們想要使用的主機共享打印機名稱還是主機?

+0

當您沒有提供有關您試圖使用的圖書館信息時,您如何期待任何人提供幫助?這是一個OSS項目,你自己寫的東西還是商業工具?你的評論無助於澄清「PrintSendLPR」類的接口,或者當這是你的不確定性時,它是否正確。不要粗魯,但如果你能提供更多的信息,可能會提供一些幫助。 – jimcavoli

回答

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; 
      } 
     }