0

I'm trying to print with a Toshiba 4610-1nr, compatible with escpos, emulating Epson TM-T88II a receipt.
All works but not the QR code.

I tried some code but none works

I'm able to print everything, but not the QR code, the barcode works... but not the QR code.

<?php
header('Content-Type: text/html; charset=utf-8');
/* ASCII constants */
const ESC = "\x1b";
const GS="\x1d";
const NUL="\x00";
const BAR="\x1c";


/* Output an example receipt */
define('EURO',chr(128));
echo ESC."t".chr(19); // table 19 lituana // 858 multilingual
echo ESC."a".chr(0); // Left print
echo "MY PLACE\n";
echo ESC."a".chr(0); // Left print
echo "Description my place\n";
echo ESC."a".chr(0); // Left print
echo "Adress my place\n";
echo ESC."a".chr(1); // Center print
echo " \n";
echo " \n";
echo " \n";
echo "header text\n";
echo "header text\n";
echo " \n";
echo " \n";
echo ESC."a".chr(0); // Left print
echo "DESCRIPTION";
echo ESC."a".chr(2); // right print
echo "VAT ";
echo "PRICE(".EURO.")";
echo ESC."a".chr(0); // Left print
echo ESC."!".chr(16); // doppia altezza
echo "SUBTOTAL\n";
echo ESC."!".chr(0); // 4 Blank lines
echo ESC."a".chr(0); // Left print
echo "VAT\n";
echo " \n";
echo "Importo pagato\n";
echo " \n";
echo ESC."a".chr(1); // Center print

echo ESC."d".chr(1); // Blank line
echo GS."h".chr(60); // seleziono hight
echo GS."w".chr(1); // seleziono widht
echo GS."m".chr(8); // code128
echo GS."k".chr(4)."0000MFDFMD0000".chr(0);
echo ESC."d".chr(1); // Blank line

echo ESC."d".chr(1); // Blank line
echo GS."k".chr(4)."70707007";
echo ESC."d".chr(1); // Blank line

echo ESC."d".chr(1); // Blank line
//echo GS."k".chr(49).chr(81)."fdhfhsl";
//echo GS."k".chr(49).chr(81)."fdhfhsl";

echo ESC."d".chr(1); // Blank line
//echo qr code GS."k".chr(28).chr(4).chr(49).chr(81)."httpsooostackoverflowocomom44";

//echo ESC."v".chr(1); // Blank line
echo ESC."V".chr(66).chr(0); // Cut
exit(0);
?>
Vikrant
  • 4,920
  • 17
  • 48
  • 72
pette
  • 67
  • 2
  • 13

1 Answers1

0
def generate_qr(self, data, size= b'\x09'):
    return b'\x1D\x28\x6B\x04\x00\x31\x41\x32\x00\x1D\x28\x6B\x03\x00\x31\x43' + size + \
           b'\x1D\x28\x6B\x03\x00\x31\x43\x51' + b'\x1D\x28\x6B' \
           + (len(data) + 3).to_bytes(2, byteorder="little") + \
           b'\x31\x50\x30' + data.encode() + b'\x1D\x28\x6B\x03\x00\x31\x51\x30'

this will output

b'\x1d(k\x04\x001A2\x00\x1d(k\x03\x001C\x04\x1d(k\x03\x001CQ\x1d(k=\x001P01111111111111111111111111111112222222222tyrytryryt12312312\x1d(k\x03\x001Q0'

if you echo -en '\x1d(k\x04\x001A2\x00\x1d(k\x03\x001C\x04\x1d(k\x03\x001CQ\x1d(k=\x001P01111111111111111111111111111112222222222tyrytryryt12312312\x1d(k\x03\x001Q0' >/dev/usb/lp0 #considering lp0 is your thermal printer will print you the qr code

ThunderHorn
  • 1,975
  • 1
  • 20
  • 42
  • Hi, the problem the code so at now I can print the Qr CODE with: `GS O 1 3 0 "145645-3434-34456ABAB564645454389084093804830984903890436".NUL` – pette Jun 02 '19 at 00:32
  • @pette you should have function with alignment to call `echo -en '\x1B\x61\x01' > dev/usb/lp0` will align center – ThunderHorn Jun 06 '19 at 09:28