如何使用PHP Windows打印到Star sp700热敏打印机
我正在使用PHP创建基于web的销售点应用程序。此应用程序必须可以打印到热敏打印机。我使用星型SP700。我已经安装了打印机驱动程序,并用“打印机测试页”进行了测试,它的工作原理也是如此 我尝试使用Mike42/escpos并遵循文档中的说明如何使用PHP Windows打印到Star sp700热敏打印机,php,thermal-printer,escpos,Php,Thermal Printer,Escpos,我正在使用PHP创建基于web的销售点应用程序。此应用程序必须可以打印到热敏打印机。我使用星型SP700。我已经安装了打印机驱动程序,并用“打印机测试页”进行了测试,它的工作原理也是如此 我尝试使用Mike42/escpos并遵循文档中的说明 require_once APPPATH.'vendor/autoload.php'; use Mike42\Escpos\Printer; use Mike42\Escpos\PrintConnectors\FilePrintCo
require_once APPPATH.'vendor/autoload.php';
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
$connector = new FilePrintConnector("php://stdout");
$printer = new Printer($connector);
$printer -> text("Hello World!\n");
$printer -> cut();
$printer -> close();
但是这个脚本给了我一个空白页,没有打印任何东西(在屏幕和打印机上)。我用的是Windows10。如何解决这个问题?我希望我的PHP脚本可以打印到热敏打印机。设置模式不同吗?如何根据手册或设置工具更改打印机模式和设备驱动程序@如果我仍然面临问题。但是从中找到了另一种解决方案,虽然这段代码可能会解决这个问题,但如何以及为什么解决这个问题将真正有助于提高您的帖子质量,并可能导致更多的投票。请记住,你是在将来回答读者的问题,而不仅仅是现在提问的人。请在回答中添加解释,并说明适用的限制和假设。
use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
use Mike42\Escpos\CapabilityProfile;
$profile = CapabilityProfile::load("SP2000")
$connector = new WindowsPrintConnector("smb://computer/printer");
$printer = new Printer($connector, $profile);