我已经用PHP语言在iis上编写了一个应用程序。这个应用程序是食物预订。这个应用程序必须从面部阅读器设备中获取数据,然后将打印发送到热敏打印机。这个应用程序可以从面部阅读器设备获得数据,但我的问题是,当我想发送打印到打印机,这是共享的,我无法实现。实际上,我想使用php和iis向共享打印机(而不是通过浏览器)发送一个文本文件,我想问您解决方案是什么?
我读过很多文章,但到目前为止还没能完成。请注意,我想发送打印使用php和不使用浏览器。并且必须使用php直接发送到打印机。
系统规格:
IIS诉8.5
PHP v. 5.6.31
windows 2012 r2
我已经测试了下面的代码,我遇到了以下问题:
1-通过excec函数直接将打印发送到打印机:
exec(' notepad /PT "c:\inetpub\wwwroot\test\goodtest.txt" "\\\192.168.10.21\BIX"')
问题是,当我使用这种方法时,我无法在windows服务器2012 r2中发送打印。
2-通过bat文件发送:一个bat文件包括以下代码:
notepad /P "c:\inetpub\wwwroot\test\goodtest.txt"
一个php文件包含以下代码:
system("cmd /c c:\inetpub\wwwroot\test\d.bat");
密码不起作用。
3-通过打印php扩展发送不起作用的.
因此,请指导我如何使用php和iis 直接将打印发送到打印机,而不是通过浏览器向发送共享打印机。
一些答案解释了网络打印机,但是我问的是共享打印机,而不是网络打印机。非常感谢。
发布于 2021-12-21 08:18:26
4周后我找到了解决办法。这是一种使用共享打印机的方法。使用mike42托管github插件。
require 'vendor/autoload.php';
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\CapabilityProfile;
use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
$connector = new WindowsPrintConnector("smb://computername/printername");
$printer = new Printer($connector);
$printer -> text("hello world");
$printer -> text("\n");
$printer -> text("\n");
$printer -> text("hello again");
$printer -> cut();
$printer -> close();
https://stackoverflow.com/questions/70313137
复制相似问题