簡體   English   中英

使用 PHP 打印到熱敏收據打印機

[英]Printing to a Thermal Receipt Printer using PHP

我有以下代碼,它應該能夠在熱敏收據打印機上打印一些東西。

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 打印一個?

嘗試這個 ...

<?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');
}
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM