使用 PHP 打印到外部收据打印机
我正在尝试找到一种将实时订单发送到收据打印机的解决方案。
基本上是伪代码:
if ($order == 'success')
{
$printer = ip.to.remove.printer;
$receipt_text = 'You just received an order!';
$ch = curl_init('http://addresstosomekindofapi.com/print_receipt/');
curl_setopt($ch, SOME_OPTION, 0).............;
curl_exec($ch);
curl_close($ch);
}
我只是在探索完成此任务的选项。如果能够做到这一点,而不是发送经常需要线路占用的传真,那真是太棒了。
如何才能实现这一目标呢?
I'm trying to find a solution for sending live orders to a receipt printer.
Basically in pseudo-code:
if ($order == 'success')
{
$printer = ip.to.remove.printer;
$receipt_text = 'You just received an order!';
$ch = curl_init('http://addresstosomekindofapi.com/print_receipt/');
curl_setopt($ch, SOME_OPTION, 0).............;
curl_exec($ch);
curl_close($ch);
}
I'm just exploring options in getting this done. It would be awesome to be able to do this rather than send faxes which often have tied up lines, etc, etc.
How could one achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对我来说,一个可靠的解决方案是构建一个连接到 Web 应用程序并能够将作业发送到打印机的桌面应用程序。我认为 Web 应用程序无法拥有太多控制权来处理用户的打印作业。
To me, a solid solution is to build a desktop application that is connected to your web application and has the ability to send jobs to the printer. I don't think a web application can have much of control as to handle user's print jobs.
有一些打印机(我猜像你的基本办公室惠普激光打印机)可以
如果我是你,我会调查一下。
(这是假设打印机和 php 文件之间存在某种网络隔离。)
There are printers (like your basic office hp laserjets I guess) that can
I'd look into that if I were you.
(this was assuming there is some sort of network separation between the printer and the php file.)
我认为解决您的问题的最佳解决方案是使用用于打印到 pdf 的 php 类将文档打印到 pdf。这样的班级还有不少。一个很好的类是
ezpdf
类,可以从 http://www.ros 下载.co.nz/pdf 或 http://www.sourceforge.net/projects/ pdf-phpI think that the best solution to your problem is printing the document to pdf using a
php
class for printing to pdf. There are quite a few of such classes. A good one isezpdf
class which can be downloaded from http://www.ros.co.nz/pdf or http://www.sourceforge.net/projects/pdf-php