从 PHP 应用程序通过网络打印
我有一组通过网络连接的打印机,并为每台打印机分配了静态 IP。
现在我有一个在 Linux 服务器上运行的 PHP Web 应用程序,它需要通过网络向这些打印机发送打印作业。
使用 lpr 或杯子是否可以实现这一点,我该如何进行?
I have a set of printers connect over a network with Static IP assigned to each printer.
Now i have a PHP web application running on a linux server which needs to send print jobs, to these printer over the network.
Is this possible using lpr or cups and how do i go about it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以从这里使用 LPR Printer 类:
http://www.phpclasses。 org/package/2540-PHP-Abstraction-for-printing-documents.html
示例:
You could use the LPR Printer class from here:
http://www.phpclasses.org/package/2540-PHP-Abstraction-for-printing-documents.html
Example:
这个问题之前已经被问过。请参阅使用 PHP 打印到网络打印机
当时给出的答案是
exec("lpr -P 'printer' -r 'filename.txt');
但是,答案从未被接受,所以不确定 OP 是否认为它有帮助;它看起来确实应该这样做技巧,但这并不是一种在 PHP 中实现的直接且简单的方法,
我发现许多其他资源也推荐了这种方法的变体,
我发现 PHP 在 PECL 中有一个打印机模块。然而,它仅适用于 Windows,并且看起来维护得不好,但如果它有帮助,请在此处链接:http://www.php.net/manual/en/intro.printer.php
我认为最终的答案是 PHP 并不是真正为这种事情而设计的,并且没有内置的功能来做到这一点,但是由于您可以使用 exec() 和类似的命令来执行外部命令,所以让它工作应该不会太难,尽管不是很困难。理想的。
This question has been asked before. See print to a network printer using PHP
The answer given that time was
exec("lpr -P 'printer' -r 'filename.txt');
However, the answer was never accepted so not sure whether the OP found it helpful; it certainly looks like it ought to do the trick, but it's not quite a direct and easy method of doing it from within PHP.
A number of other resources I found were also recommending variations on this approach.
Digging a bit deeper, I see PHP has got a Printer module in PECL. However it's only for Windows, and looks like it's not well maintained. But in case it helps, the link it here: http://www.php.net/manual/en/intro.printer.php
I think the answer ultimately is that PHP isn't really designed for this kind of thing, and doesn't have built-in functionality to do it. But since you can shell out to external commands using
exec()
and similar, it shouldn't be too hard to get it working, albeit not quite ideal.尝试 PHP::PRINT::IPP
它对我来说非常有效。
基本用法
参考
Try PHP::PRINT::IPP
It worked perfectly for me.
Basic Usage
Reference
我也在对此进行研究......我认为下面编写的代码可以帮助您在Linux中处理打印机
i was also doing research on this...and i think the below written code can help you in handling printer in linux