Android Question Printing ESC/POS problem

Juanll2003uy

Member
Licensed User
Longtime User
Hi, im sending to print to a bluetooth printer with the code below.
In the file "impesion.txt" (that upload with this message) there is ESC/POC comands, the printer is ESC/POS compatible.
But when it prints the images arent images else rares symbols.
Im doing something wrong?
Thanks

Sub Imprimir
PrintBuffer=File.ReadString(File.DirDefaultExternal, "impresion.txt")
StartPrinter
End Sub

Sub StartPrinter
Dim PairedDevices As Map
Dim L As List
Dim Res As Int

ToastMessageShow("Printing.....",True)

PairedDevices.Initialize

Try
PairedDevices = cmp20.GetPairedDevices
Catch
Msgbox("Getting Paired Devices","Printer Error")
printer.Close
cmp20.Disconnect
End Try

If PairedDevices.Size = 0 Then
Msgbox("Error Connecting to Printer - Printer Not Found","")
Return
End If

If PairedDevices.Size = 1 Then
Try
cmp20.ConnectInsecure(btAdmin,PairedDevices.Get(PairedDevices.GetKeyAt(0)),1)
Catch
Msgbox("Connecting","Printer Error")
printer.Close
cmp20.Disconnect
End Try
Else
L.Initialize

For i = 0 To PairedDevices.Size - 1
L.Add(PairedDevices.GetKeyAt(i))
Next

Res = InputList(L, "Choose device", -1)

If Res <> DialogResponse.CANCEL Then
cmp20.Connect(PairedDevices.Get(L.Get(Res)))
End If
End If
End Sub

Sub Printer_Connected (Success As Boolean)
If Success Then
printer.Initialize(cmp20.OutputStream)
printer.WriteLine(PrintBuffer)
printer.Flush

Msgbox("Printed!","")
printer.Close
cmp20.Disconnect
Else
If Msgbox2("", "Printer Error","Reprint","Cancel","",Null) = DialogResponse.POSITIVE Then
StartPrinter
End If
End If
End Sub
 

Attachments

  • impresion.txt
    27.8 KB · Views: 325

Juanll2003uy

Member
Licensed User
Longtime User
I need to print "impresion.text" content like bytes in the printer.
Because the printer take it like text else and not like esc/por commands.
 
Upvote 0
Top