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

时间:2014-12-02 01:51:10

标签: php qr-code epson

我尝试在epson pos TM-T88V形式的php中打印qr代码,但我不能。我从epson-biz.com获得的信息根本不清楚,我搜索并且没有任何关于正确的陡峭打印QR码的例子。我打印文本没问题,但二维码无效。这是我跟随有关ESC-POS的epson文档的代码:

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

例如,我从epson-biz.com获得的文档说的是函数165(我尝试在我的php代码中遵循小数部分):

    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.

请使用ESC-POS命令成功打印QR码的人?我不知道功能(165,167,169,180,181,182)的顺序是否正确。

2 个答案:

答案 0 :(得分:1)

改变这个:

fwrite($handle, chr(29).chr(40).chr(107).chr(3).chr(0).chr(49).chr(80).chr(48)); // Function 180

为此:

fwrite($handle, chr(29).chr(40).chr(107).chr(31).chr(0).chr(49).chr(80).chr(48)); // Function 180

<Function 180> GS ( k pL pH cn fn m d1…dk (cn = 49, fn = 80)

k = (pL + pH x 256) – 3

k =你想打印多少个字符?,你发送“TEXTO DE PRUEBA DE CODIGO QR”(28)。

k = (31 + 0 x 256) - 3
k = (31 + 0) - 3
k = 31 - 3
k = 28

所有其他事情都遵循命令的默认值。

答案 1 :(得分:0)

我发现你遇到的问题至少在下面是打印二维码的一个例子,请尝试在cups linux上配置你的打印机,并在使用命令echo -e&#34; \ x&#34; | lpr -P,这个例子很好用:

1D 28 6B 03 00 31 43 04 1D 28 6B 03 00 31 45 33 1D 28 6B 0d 00 31 50 30 //注意0d = 13个字符 56 69 76 61 20 43 68 69 6c 65 // 10个字符 1D 28 6B 03 00 31 51 30 00 1B 33 00 00 0A 1D 56 42 00 1B 32 //行间距,进纸和切纸......

我希望上面的代码可以为您提供支持。