我有php 5.2.4的centos 5。我有一個文件,html,我想打印。我怎麼能在Linux上做到這一點。我似乎無法找到任何關於它的任何地方。它只是所有的窗口的東西。我想用客戶打印機打印。我試過以下哪個錯誤。如何發送文件到打印機上使用php的centos 5.2.4
$handle = printer_open();
printer_write($handle, "Text to print");
printer_close($handle);
[Wed May 22 08:00:27 2013] [error] [client 172.16.0.85] PHP Fatal error: Call to undefined function printer_open() in /opt/invload/protected/controllers/SiteController.php on line 485, referer: http://portal-dev/invload/index.php?r=site/report&view=report
我正在使用Yii框架和我正在查看的頁面打印分頁。做window.print
將不會打印所有的結果,所以我做了一個jQuery的查詢所有結果和輸出到文件。現在我想打印該文件。
在我看來
<?php
$this->pageTitle=Yii::app()->name . ' - Reports';
?>
<style type="text/css">
.odd {
background: none repeat scroll 0 0 #E5F1F4;
}
.even {
background: none repeat scroll 0 0 #F8F8F8;
}
table tbody tr:hover{
background: none repeat scroll 0 0 lightgreen;
}
table tbody tr{
font-size:10pt;
}
body
{
margin: 0mm 0mm 0mm 0mm;
}
</style>
<body onload="window.print();window.close();">
<table>
<tr>
<th>No_</th>
<th>Pay-to Name</th>
<th>Order No</th>
<th width="50px">Vendor Invoice No</th>
<th>Log Number</th>
<th width="65px">Posting Date</th>
</tr>
<?php
$count = 0;
$class= null;
foreach($dataProviderAll->getData() as $q) {
$class = ($count % 2 === 0) ? 'odd' : 'even';
$this->renderPartial('_report',array('data'=>$q,'class'=>$class));
$count++;
}
?>
</table>
</body>
在我的控制器
public function actionPrint(){
$company = Yii::app()->params['currentCompany'];
$query = Yii::app()->dbNav->createCommand("SELECT [No_] AS [no],[Pay-to Name] AS [paytoname],[Order No_] AS [orderno],[Vendor Invoice No_] AS [vendorinvoiceno], [Log Number] AS [lognumber],[Posting Date] AS [postingdate]
FROM [$company\$Purch_ Inv_ Header] WHERE [Log Number] is not null and [Log Number] not in (
SELECT [InvoiceLogNo] FROM [$company\$Invoice Image Locations])
ORDER BY " . $this->order . " " . Yii::app()->session['asc_or_desc'])->queryAll();
//print_r(count($query));
$dataProviderAll = new CArrayDataProvider($query);
$item_count = count($query);
$pages = new CPagination($item_count);
$pages->setPageSize($item_count);
$dataProviderAll->setPagination($pages);
$print = $this->renderPartial('print',array('dataProviderAll'=>$dataProviderAll),true);
//print_r($print);
$file = "/tmp/reports.html";
file_put_contents($file, $print);
header("Content-disposition: attachment;filename=$file");
readfile($file);
}
你的意思是服務器端的打印機?使用瀏覽器 –
客戶端打印機 – shorif2000