0

I'm trying to print a QR on a generic printer using xamarin forms, when I print text I don't have problems, but when I want to print a QR code I can't. I thought it was the printer but in its demo print it does show qrs codes

**qrCodeData **has a base 64 QR code and **qrCodeBytes **is the conversion in array,

in this line bluetoothSocket?.OutputStream.Write(qrCodeBytes, 0, qrCodeBytes.Length); should print

public async Task Print(string deviceName, string text)
        {

            BluetoothDevice device = (from bd in bluetoothAdapter?.BondedDevices
                                      where bd?.Name == deviceName
                                      select bd).FirstOrDefault(); 

            string qrCodeData = Base64CodeQR();
            byte[] qrCodeBytes = Convert.FromBase64String(qrCodeData);          

            try
            {                 
              
                BluetoothSocket bluetoothSocket = device?.
                CreateRfcommSocketToServiceRecord(
                UUID.FromString("00001101-0000-1000-8000-00805f9b34fb"));

                bluetoothSocket?.Connect();
             
                bluetoothSocket?.OutputStream.Write(qrCodeBytes, 0, qrCodeBytes.Length);                 

                await Task.Delay(1000);

                bluetoothSocket.Close() ;
              

            }
            catch(Exception exp)
            {
                
                throw exp;
            }

            
        }
  • there is no such thing as a "generic bluetooth printer". Assuming you're talking about a receipt type printer, they support different printer languages and command sets. They may have built in QR capabilities, or you may need to send the data as a bitmap. Without knowing any detail about the printer you are actually using its difficult to provide any specific answer. – Jason Aug 12 '23 at 21:25
  • @Jasón , The printer works with any code, they do not have their own sdk established – Nicker Pasco Aug 12 '23 at 21:35
  • Even simply stating the exact vendor name and model number of the printer you are trying to use will help you get advice. Also, even if there is no integrated software or system called SDK, there may be documents such as user's manuals or ESC/POS command references, so why not try looking for them? – kunif Aug 12 '23 at 22:19

0 Answers0