【问题标题】:Printing to a Thermal Receipt Printer using PHP使用 PHP 打印到热敏收据打印机
【发布时间】:2014-02-07 04:24:12
【问题描述】:

我有以下代码,它应该能够在热敏收据打印机上打印一些东西。

if ($_GET['action'] == 'print')
{
    $printer = "\\\\localhost\\zebra";

    // Open connection to the thermal printer
    $fp = fopen($printer, "w");
    if (!$fp){
      die('no connection');
    }

    $data = " PRINT THIS ";

    // Cut Paper
    $data .= "\x00\x1Bi\x00";

    if (!fwrite($fp,$data)){
      die('writing failed');
    }

}

虽然,当我运行它时,什么也没有发生,也没有错误。如何从 PHP 打印?

【问题讨论】:

  • 使用printer_open函数怎么样....php.net/manual/en/function.printer-open.php
  • 它给了我这个:Call to undefined function printer_open()
  • 嗯,只是猜测,你fclose你的实际代码吗?
  • 尊敬的@user3271851,您找到解决方案了吗?如果您有解决方案,请帮助。谢谢。

标签: php printing


【解决方案1】:

试试这个...

<?php 
if ($_GET['action'] == 'print')
{
$printer = "\\\\localhost\\zebra"; 
if($ph = printer_open($printer)) 
{ 
   $data = " PRINT THIS ";  
   // Cut Paper
   $data .= "\x00\x1Bi\x00";
   printer_write($ph, $data); 
   printer_close($ph); 
} 
else die('writing failed');
}
?>

【讨论】:

  • 我收到此错误:Call to undefined function printer_open()
  • 你在 php.ini 中启用了扩展吗?
  • 我会在 php.ini 文件中放什么?
猜你喜欢
  • 1970-01-01
  • 2017-03-12
  • 2013-07-04
  • 2019-04-14
  • 2015-10-25
  • 2020-04-01
  • 2020-02-18
  • 2013-03-16
  • 2015-07-29
相关资源
最近更新 更多