Android Question EscPosPrinter QRCode

Pantelis Loizou

Member
Licensed User
Longtime User
hi to everyone

I have a photo saved in mssql and I want to print it as a qrcode on a bluetooth printer

does anyone manage to complete this
 

Pantelis Loizou

Member
Licensed User
Longtime User
Hi aeric

i need to print QR code and IT SHOULD BE SCANNED

The printer is 58mm width

The EscPosPinter has the following sub but i couldn't manage to send data
B4X:
Public Sub WriteQRCode(size As Int, EC As String, scale As Int, data As String)
    Dim databytes() As Byte = data.GetBytes("ISO-8859-1")
    Dim dhigh As Int = databytes.Length / 256
    Dim dlow As Int = databytes.Length - dhigh*256
    Log("QR Code : Size " & size & ", EC " & EC & ", Scale " & scale & ", Size " & dlow & " " & dhigh & " : Data = " & data)
    Dim params(3) As Byte
    params(0) = scale
    params(1) = dlow
    params(2) = dhigh
    WriteString(ESC & "Z" & Chr(size) & EC.ToUpperCase.CharAt(0))
    WriteBytes(params)
    WriteBytes(databytes)
End Sub
 
Upvote 0

Pantelis Loizou

Member
Licensed User
Longtime User
here is the complete code
B4X:
Starter.Crsr = Starter.sqlServer.ExecQuery2("SELECT * FROM EInvoicingIFC WHERE invoice_number=? AND store_id=? AND type=?", Array As String (InvoiceNumber, Main.StoreID,"C"))
            Do While Starter.Crsr.NextRow
                EINVuid = Starter.Crsr.Getstring("uid") ' 7B6F3E378B163C8DEA019047D1E3E7F4E2D0A004
                EINVmark = Starter.Crsr.GetString("mark") '400001928271942
                EINVSignature = Starter.Crsr.GetString("signature") 'EL094196225-1451215-E12E2B05F4F061C5681CD6D549D1A6BA6EACAE41-788CDC5CE91C4657949BE75FE5E36D70
                EINVDomain = Starter.Crsr.GetString("domain") 'https://einvoiceportaluat.impact.gr
                EINVQRcode = Starter.Crsr.GetBlob("qrcode")    'this is varbinary(MAX)
            Loop

            If EINVmark<>"" Then
                Main.Printer.WriteString(Main.Printer.BOLD & "UID: " & EINVuid & Main.Printer.SINGLE & CRLF)
                Main.Printer.WriteString(Main.Printer.BOLD & "Mark: " & EINVmark & Main.Printer.SINGLE & CRLF)
                Main.Printer.WriteString(Main.Printer.BOLD & "Signature: " & EINVSignature & Main.Printer.SINGLE & CRLF)
              
                Dim QRtext As String = EINVDomain & "/v/" & EINVSignature
                Main.Printer.WriteQRCode(512, "M", 3, QRtext)
            Else
                Main.Printer.WriteString(Main.Printer.BOLD & "Entity unable to communicate with the provider" & Main.Printer.SINGLE & CRLF)         
            End If
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I don't understand your question.

To print QRCode on bluetooth thermal printer using ESC/POS, there are 2 ways.

1. If the printer supports QRCode, then you just need the correct command.
2. Else, you need to convert and print it as image.
 
Upvote 0

Pantelis Loizou

Member
Licensed User
Longtime User
I don't understand your question.

To print QRCode on bluetooth thermal printer using ESC/POS, there are 2 ways.

1. If the printer supports QRCode, then you just need the correct command.
2. Else, you need to convert and print it as image.
sorry for the misunderstanding and my English. what i need exactly is to read from mssql database a varbinary field and print it on a Bluetooth printer as a QRCode. is there any example how to do that? i trying with above code but nothing happen. i am try to print as image but i cannot scan it. should by scanned after printing.

I hope I made myself clear
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
EINVQRcode
I don't see you use this object.
If it is an image file, you need to convert it to monochrome bitmap to print.

i couldn't manage to send data
What you mean?
Do you mean the printer doesn't print anything with this code?

To check whether your printer can print QRCode, you need to do self test. Turn off the printer, press and hold the paper feed button while pressing the power button.
If the sample prints QRCode, then it supports printing QRCode. Else you need to print as image.

If your QRCode image failed to scan by scanner or mobile camera then maybe it is because the quality is too low or blur. It exceeded the error correction allowed by the scanner software. Make sure to generate a higher quality image.
 
Upvote 0
Top