doubi8383 2014-12-02 01:51
浏览 96

如何从php中打印epson tm-t88v中的qr代码

I try print qr code in a epson pos TM-T88V form php and I can't. The information I get from epson-biz.com is no clear at all, and I search and no get any example about the correct steeps to print QR code. I print text no problems, but QR code no work. This is the code I tri follow the epson documentation about ESC-POS:

if(($handle = @fopen("LPT1", "w")) === FALSE){
    die('I can't print, check your connection');
}

fwrite($handle,chr(27). chr(64));//restart    
fwrite($handle, chr(27). chr(100). chr(0));
fwrite($handle, chr(27). chr(33). chr(8));
fwrite($handle, chr(27). chr(97). chr(1));
fwrite($handle,"=================================");
fwrite($handle, chr(27). chr(100). chr(1));
fwrite($handle, chr(27). chr(32). chr(3));
fwrite($handle," No 1005 ");
fwrite($handle, chr(27). chr(32). chr(0));
fwrite($handle, chr(27). chr(100). chr(0));
fwrite($handle, chr(27). chr(33). chr(8));
fwrite($handle, chr(27). chr(100). chr(0));
fwrite($handle, chr(27). chr(100). chr(1));
fwrite($handle,"=================================");
fwrite($handle, chr(27). chr(100). chr(3));
// to here work, but the rest is the problem:
    fwrite($handle, chr(29).chr(40).chr(107).chr(4).chr(0).chr(49).chr(65).chr(50).chr(0));  // Function 165
    fwrite($handle, chr(29).chr(40).chr(107).chr(3).chr(0).chr(49).chr(67).chr(20)); // Function 167 
    fwrite($handle, chr(29).chr(40).chr(107).chr(3).chr(0).chr(49).chr(69).chr(48)); // Function 169
    fwrite($handle, chr(29).chr(40).chr(107).chr(3).chr(0).chr(49).chr(80).chr(48)); // Function 180
    fwrite($handle,"TEXTO DE PRUEBA DE CODIGO QR");  // this text go to QR
    fwrite($handle, chr(29).chr(40).chr(107).chr(3).chr(0).chr(49).chr(81).chr(48)); //Function 181
    fwrite($handle, chr(29).chr(40).chr(107).chr(3).chr(0).chr(49).chr(82).chr(48)); //Function 182

fwrite($handle, chr(27). chr(100). chr(6));
fwrite($handle, chr(29). chr(86). chr(1));// cut paper


fclose($handle); 
$exitmsj = shell_exec('lpr LPT1');

For example, the documentation I get from epson-biz.com say about Function 165 (I try to follow decimal part in my php code):

    GS ( k   <Function 165>
________________________________________
[Models]    •   TM-J2000
•   TM-J2100
•   TM-L90
•   TM-P60
•   TM-P60II
•   TM-P80
•   TM-T20
•   TM-T20II
•   TM-T70
•   TM-T70II
•   TM-T82II
•   TM-T88IV
•   TM-T88V
•   TM-T90
•   TM-U220
•   TM-U230
[Name]  QR Code: Select the model
[Format]    ASCII       GS      (       k       pL      pH      cn      fn      n1      n2
Hex     1D      28      6B      04      00      31      41      n1      n2
Decimal     29      40      107     4       0       49      65      n1      n2

[Range] (pL + pH × 256) = 4 
cn = 49 
fn = 65 
n2 = 0 
n1: different depending on the printers
[Default]   n1 = 50, n2 = 0
[Description]   Selects the model for QR Code.
n1  Function
49  Selects model 1
50  Selects model 2
51  Selects Micro QR Code

[Notes]    Settings of this function affect the processing of Function 181 and 182.
   Settings of this function are effective until ESC @ is executed, the printer is reset, or the power is turned off.

Please someone who succeeded in print QR code using comands ESC-POS? I don't know if the order of the Functions (165, 167, 169, 180, 181, 182) are correct.

  • 写回答

2条回答 默认 最新

  • duanhe8280 2014-12-17 05:13
    关注

    I see that you have the same problems I had at least below is one example to print QR code, please try to configure your printer on cups linux and after use the commands echo -e "\x" | lpr -P , this example work fine:

    1D 28 6B 03 00 31 43 04 1D 28 6B 03 00 31 45 33 1D 28 6B 0d 00 31 50 30 //Note 0d = 13 chars 56 69 76 61 20 43 68 69 6c 65 // 10 chars 1D 28 6B 03 00 31 51 30 00 1B 33 00 00 0A 1D 56 42 00 1B 32 //line spacing, feed, and cut paper...

    I hope above code can support you.

    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?