- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有 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
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);
}
最佳答案
您正在谈论客户端打印,因此您需要使用客户端技术,即 Javascript。
您可以调用 window.print() 来打印事件窗口。在这里检查:
http://www.w3schools.com/jsref/met_win_print.asp
如果您希望控制正在打印的内容(例如设置横向/纵向打印),您可以使用浏览器插件。对于 Firefox,您可以使用 jsprintsetup 执行此操作:
https://addons.mozilla.org/en-us/firefox/addon/js-print-setup/
编辑 : 更新后,问题中添加了更多信息。在下面添加其他回复。
在这种情况下,您可以在新页面中打开包含组合结果的页面并打印。或者,您可以在不可见的选项卡中输出所有结果并打印其内容
编辑2 (回复下面的评论):
要使用您的数据打开一个新窗口,您可以使用 window.open() 从 javascript 执行此操作:
window.open("site.com/something.php?param1=1¶m2=2");
window.print();
window.close();
$("<iframe id=\"printFrame\" src=\"" + yourURL + \" width=\"0\" height=\"0\" frameborder=\"0\" scrolling=\"no\"/>").insertAfter($('body'));
关于php - 如何使用php 5.2.4将文件发送到centos上的打印机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16688337/
我有一个代理类,它接收请求并将请求发送到另一台服务器,获取响应并将其定向回原始请求者。我使用套接字连接到服务器并使用 Printwriter 对其进行写入。像这样的事情 private Pri
我想使用 Java Swing 为医疗商店开发一个独立的应用程序。强制要求在没有打印对话框的情况下单击一下即可打印小尺寸(219 毫米至 140 毫米)的纸张。他们需要间歇性地将报告从不同的打印机打印
我是一名学生,需要创建一个 silten 打印功能,希望能够打印 PDF。这个需要基于Java。 我在 Google 上搜索并找到了一个无需对话框即可打印的代码。但如果源是 .txt 文件,它就会正确
我正在寻找 POS 打印的解决方案。 场景是: 一家餐厅目前有一个 POS 系统启动并运行,他们从店内的 iPad 上接受订单,并有一个网络设置来处理订单并在厨房的热敏打印机上自动打印出来(很酷,对吧
尝试使用以下代码示例,它在 WinForm 应用程序中运行良好,但在 VSTO 中运行不佳。是否有某种允许访问的权限? 可以设置默认打印机,但不能获取或设置打印机设置。 从插件中获取以下异常: Sys
我必须通过蓝牙将字体文件发送到我的打印机 Zebra RW420。我正在使用 Zebra Windows Mobile SDK,但无法找到任何方式将其发送和存储在打印机上。我可以通过 Label Vi
我需要创建一个“粉碎”的虚拟打印机 基本上这是我的问题。我有一个软件程序需要在保存文件之前“打印”文件。我希望能够打印到我的碎纸机,以便它保存文档,但实际上我不想打印文档。所以我需要打印到一个程序,该
我在吃 Argox 标签打印机时遇到了麻烦,只是仍然无法向她发送任何内容。型号为 Argox OS214 tt,ANPP,接受 PPLB。 使用通用类连接串行设备,我将她用于多个财务打印机和秤,附后。
我正在编写一些在 org.eclipse.swt.printing.Printer 上打印的代码。所以第一步是看看我如何测试它,但似乎架构不允许我定义自己的打印机,因为 PrinterData 和 P
我有一个标签列表,数据如下。 ['id', 'Version', 'chip_name', 'xversion', 'device', 'opt_param', 'place_effort'][1,
我正在开发一个应用程序,在该应用程序中,我通过 IP 地址和端口号从我的手机向 WiFi 打印机发送文件,这些文件是 .txt、.png、.jpg、.doc。它们应该从打印机打印出来。我尝试了以下代码
我正在尝试使用以下代码打印图像,但文档只是停留在打印作业队列中,拒绝打印。在 (windows) 打印作业队列中,我得到: DocumentName: Printing an image Status
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: Print preview ZPL II commands using .NET WinForm befor
我有什么 我目前正在编写一个程序,它接受一个指定的文件并对其执行一些操作。目前它打开它,和/或将它附加到电子邮件并将其邮寄到指定地址。 文件可以是以下格式:Excel、Excel Report、Wor
我将这台 Zebra ZM400 打印机连接到网络 (192.168.1.50)。我正在尝试直接从 PHP 将内容推送到这台打印机。 这就是我的想法,但我无法做到这一点。我尝试了 file_put_c
我想显示一个列表,其中包含设备可通过 AirPrint 访问的所有打印机。 我使用 UIPrinterPickerController 让它工作。 是否有以自定义方式显示此 PickerControl
我想将任何办公文件传输到 Wi-ifi 打印机。我完全不知道如何开始。 发现没有用于无线打印的公共(public) API。 谁能分享一些意见? 提前致谢! 最佳答案 您可以首先扫描 WiFi 设备并
有什么方法可以让我在蓝牙热敏打印机上打印收据,因为我真的很难在 flutter 上找到解决方案?任何事情都有帮助,我真的很感激这些答案 最佳答案 我试过 esc_pos_bluetooth 包,但它不
为了在我的 mac 上模拟 ZPL 打印机,我在互联网上搜索了几天。最后,我有一个解决方案可以在这里发布,这样其他用户可能会发现它有帮助。我想在这里发布我的解决方案 Emulate Zebra pri
是否有 ZPL 命令来简单地重启 Zebra 打印机?到目前为止,我只能找到 ~JR 命令,这对我来说看起来不像我正在寻找的东西。我只需要一种方法来重新启动打印机,而无需重置其任何配置。 最佳答案 以
我是一名优秀的程序员,十分优秀!