HeligPfleigh / react-native-thermal-receipt-printer

A RN library for thermal printer
175 stars 103 forks source link

support to print qrcode #139

Open iuryol opened 1 year ago

iuryol commented 1 year ago

Hello , how i can use this library for print a qrcode too , need some help . this one looks great if u guys have some way to print qrcode a i'll be very grateful

notmarinho commented 1 year ago

I really wanted that feature too!

KannarFr commented 1 year ago

Me too.

beinmedia-tech commented 1 year ago

This fork supports https://github.com/thiendangit/react-native-thermal-receipt-printer-image-qr

mustafa-altai77 commented 1 month ago

when can use this

const printQRCode = async () => { try { const qrData = 'Hello World'; const dataLen = qrData.length + 3; const pL = dataLen % 256; const pH = Math.floor(dataLen / 256);

  const commands = [
    '\x1D\x28\x6B\x03\x00\x31\x43\x08', // Set QR code size
    '\x1D\x28\x6B\x03\x00\x31\x45\x31', // Set QR code error correction level
    `\x1D\x28\x6B${String.fromCharCode(pL)}${String.fromCharCode(
      pH,
    )}\x31\x50\x30${qrData}`,
    '\x1D\x28\x6B\x03\x00\x31\x51\x30', // Print QR code
  ].join('');

  await NetPrinter.printText(commands);
  console.log(commands);
  await NetPrinter.closeConn();

  console.log('QR code printed successfully.');
} catch (error) {
  console.error('Failed to print QR code:', error);
}

};