如何从php打印EPSON TM-T88V中的二维码
我尝试在Epson pos TM-T88V表单php中打印二维码,但无法打印。我从Epson-biz.com获得的信息根本不清楚,我搜索也没有得到任何关于打印二维码的正确步骤的示例。我打印文字没问题,但二维码不行。这是三个遵循Epson文档关于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');
例如,我从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.
有没有人用Comands ESC-POS成功打印出二维码?我不知道函数(165、167、169、180、181、182)的顺序是否正确。
解决方案
更改:
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=要打印多少字符?发送"tex to de Prueba de CODIGO QR"(28)。
k = (31 + 0 x 256) - 3
k = (31 + 0) - 3
k = 31 - 3
k = 28
所有其他设置只遵循命令的默认值。
相关文章