我有 php 5.2.4 的 centos 5。我有一个文件,html,我想打印。我怎么能在linux上做到这一点。我似乎无法在任何地方找到任何关于它的信息。它只是所有Windows的东西。我想使用客户端打印机打印。我尝试了以下哪些错误。
$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);
}