【问题标题】:How to print QrCode using Epson TM-T20 printer?如何使用 Epson TM-T20 打印机打印二维码?
【发布时间】:2020-04-01 22:34:32
【问题描述】:

我正在尝试使用 EPSON TM-T20 使用 ESC POS 命令打印二维码

我可以打印简单的文本,展开,剪纸,但是当我尝试打印二维码时......不成功

我使用的是 Linux,我的打印机位于 /dev/usb/lp1。

我相信 ESC POS 命令没问题,因为有另一台打印机 (TANCA TP650) 使用相同的命令打印二维码,而这另一台打印机也没问题。

这是我在 Qt C++ 中的代码

    vetor.append(0x1D);// GS ( k pL pH cn fn n1 n2 (cn=49, fn=65)
    vetor.append(0x28);
    vetor.append(0x6B);
    vetor.append(0x04);
    vetor.append('\0');
    vetor.append(0x31);//cn=49
    vetor.append(0x41);//fn=65
    vetor.append(50);//n1 48..49 ou 49..50 ????
    vetor.append('\0');//n2

    //f67 := #29+#40+#107+#03+#00+#49+#67 + Chr(tamanho mod 17);
    vetor.append(0x1D);// GS ( k pL pH cn fn n (cn=49, fn=67)
    vetor.append(0x28);
    vetor.append(0x6B);
    vetor.append(0x03);
    vetor.append('\0');
    vetor.append(0x31);//cn
    vetor.append(0x43);//fn=67
    vetor.append(3);  //tamanho 1..16

    //f69 := #29+#40+#107+#03+#00+#49+#69+#03;
    vetor.append(0x1D);//GS ( k pL pH cn fn n (cn=49, fn=69)
    vetor.append(0x28);
    vetor.append(0x6B);
    vetor.append(0x03);
    vetor.append('\0');
    vetor.append(49);//cn
    vetor.append(69);//fn
    vetor.append(48);// error correction level 48..51 ????

    len+=3;
    qDebug() << "qrcode epson " << len << str;
    qDebug() << (len & 0xFF) << ((len & 0xFF00) >> 8);

    //f80 := #29+#40+#107 + AnsiChar(l mod 256) + AnsiChar(l div 256) + #49+#80+#48;
    vetor.append(0x1D);//GS ( k pL pH cn fn m d1...dk (cn=49, fn=80)
    vetor.append(0x28);
    vetor.append(0x6B);
    vetor.append(len & 0xFF);
    vetor.append((len & 0xFF00) >> 8);
    vetor.append(0x31);//cn
    vetor.append(0x50);//fn
    vetor.append(0x30);//m
    vetor.append(str);

    //f81 := #29+#40+#107+#03+#00+#49+#81+#48;
    vetor.append(0x1D);//GS ( k pL pH cn fn m (cn=49, fn=81)
    vetor.append(0x28);
    vetor.append(0x6B);
    vetor.append(0x03);
    vetor.append('\0');
    vetor.append(49);//cn
    vetor.append(81);//fn
    vetor.append(48);//m

谢谢

【问题讨论】:

    标签: printing qr-code epson


    【解决方案1】:

    我通常使用串行线打印这张收据。但是 /dev/usb/lp1 不是串行打印机。 我要打印的代码是:

    fprintf(打印机, pedidoprt); //pedidoprt是二维码的字节数组

    C 编译器将 \0 理解为字符串结尾!!!!

    我将代码更改为:

    文件 *printer = fopen(caminho.toUtf8(), "w");

    fwrite ( pedidoprt, sizeof(char), pedidoprt.size(), 打印机);

    fclose(打印机);

    此点已关闭!

    【讨论】:

      猜你喜欢
      • 2014-01-19
      • 2018-07-17
      • 2012-01-21
      • 2015-01-30
      • 2016-01-13
      • 2018-12-30
      • 2018-11-18
      • 2012-01-05
      • 2011-12-05
      相关资源
      最近更新 更多