Android Question Portable Bluetooth label printer

imbault

Well-Known Member
Licensed User
Longtime User
Hi,
I'm looking for a Bluetooth Portable label printer, which can print text and barcodes, and working with B4A.

Does anyone can advise on a model, reference, please ?

Many thanks
 

rboeck

Well-Known Member
Licensed User
Longtime User
Hi, some days ago i got an "mini thermal printer" with bluetooth form amazon, which is built in china and cost~ 70 € and have checked the possibilities. I have used the printer in windows, connected with usb and here the printer is working in an graphics mode. Paperwidth is 58 mm, but is only able to use 48 mm. I had cuurently no succes with bluetooth connection, but usb is me ok.
On my android devices i have currently made my tests only with bluetooth, the connection was easy and i can switch between tablet and mobile easiy.
In android we have no printer driver like in windows; so we have to look at old dos programs for esc codes. You have to know the codes for codepage, fontsize, and so on.
I plan to make an graphic logo in windows, the print it to file and then use this file before my android printing begins. Then i have to reset the printer do textmode and send my own text.
What i found out, is that the epson emulation is not perfect. I tried ready apps where i could choose epson or star emulation and i got much errors on the printout.
So my advice is very different - the work, to make different printouts in android is not easy. For mainly windows use it is a very cheap device and seems to work good enough for the most needs.
Greetings
Reinhard
 
Upvote 0

imbault

Well-Known Member
Licensed User
Longtime User
Thanks, but I'm OK with specific label printer languages Zebra... I'm just looking for a model/reference that works on Bluetooth with Android
 
Upvote 0

edgar_ortiz

Active Member
Licensed User
Longtime User
I hope it helps you.

B4X:
    ' Starter
    '
    ' Parametros de Impresion
    Dim ParPrinterName                    As String        ' PRINTER_NAME                Nombre de la Impresora                                    PRINTER
    Dim ParPrinterAddress                As String        ' PRINTER_ADDRESS            MAC address de la Impresora
    Dim ParPrinterSets                    As String        ' PRINTER_SETS                Sets al momento de inicializar la Impresora
    Dim ParPNRRepCodigo                    As String        ' PNR_REP_CODIGO            Codigo del Reporte para imprimir la Boleta                1
    Dim ParPNRHead01                    As String        ' PNR_HEAD_01                PRINTER: Caracter de Control para el encabezado # 1
    Dim ParPNRHead02                    As String        ' PNR_HEAD_02                PRINTER: Caracter de Control para el encabezado # 2
    Dim ParPNRHead03                    As String        ' PNR_HEAD_03                PRINTER: Caracter de Control para el encabezado # 3
    Dim ParPNRDet01                        As String        ' PNR_DET_01                PRINTER: Caracter de Control para el DETALLE
    Dim ParPNRTot01                        As String        ' PNR_TOT_01                PRINTER: Caracter de Control para el TOTAL # 1
    Dim ParPNRTot02                        As String        ' PNR_TOT_02                PRINTER: Caracter de Control para el TOTAL # 2
    Dim ParPNRNumLf                        As Int            ' PNR_NUM_LF                PRINTER: Numero de Lineas en Blanco al Finalizar de Imprimir la Boleta
    '
    Dim o_Serial                        As Serial        ' Objeto que contiene la comunicacion con los dispositivos
    Dim o_Printer                        As AsyncStreams    ' Objeto que contiene la informacion a imprimir
    Dim o_Printer_Conected                As Boolean        ' Indica si la impresora está conectada

'
' Connect the printer in a Activity
'
Sub Activity_Resume
    cietImpresora.Text    = Starter.ParPrinterName
    cietAddress.Text    = Starter.ParPrinterAddress
    '
    If Starter.o_Printer.IsInitialized = True Then
        If Starter.o_Printer_Conected = True Then
            cietEstado.Text    = "Conectada"
        Else
            cietEstado.Text    = "Desconectada"
        End If
    Else
        cietEstado.Text    = "Desconectada"
    End If
    '
    If Starter.o_Serial.IsEnabled = True Then
        cibutConectar.Enabled    = True
        cibutConectar.Visible    = True
    Else
        cibutConectar.Enabled    = False
        cibutConectar.Visible    = False
        '
        Msgbox("Es necesario HABILITAR el Bluetooth", "ERROR:")
    End If
End Sub
'
' A code module that print
'
Sub Verifica_Estado_Impresora As Boolean
    Dim lcResultado As Boolean
    Dim lcData As String
    lcResultado    = True
    '
    'Starter.o_Printer.Initialize(Starter.o_Serial.InputStream, Starter.o_Serial.OutputStream, "Printer")
    '
    Try
        ' Se Imprime una linea en blanco
        lcData    = Chr(10)
        Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
    Catch
        Log("Verifica_Estado_Impresora")
        Log(LastException)
        lcResultado    = False
    End Try
    '
    Return    lcResultado
End Sub

Sub Imprime_Envio
    Dim lcData            As String
    Dim lcSqlComando    As String
    Dim lcFecha            As String
    Dim lcHora            As String
    Dim lcStr            As String
    Dim lcMoneda        As String
    Dim lcTasaImpresion    As Double
    Dim lcLineasEnca()    As String
    Dim lcLineFeed        As String
    Dim lcCursorEnvio    As Cursor
    Dim lcCursorDetalle    As Cursor
    '
    ' Se verifica que esté inicializado el objeto de la Printer
    If Starter.o_Printer.IsInitialized = False Then
        Msgbox("La impresora NO está lista","Impresion de Envio")
        Return
    End If
    '
    ' Se cargan los cursores
    lcSqlComando    = "SELECT * FROM work_t_envios"
    lcCursorEnvio    = Starter.Database.ExecQuery(lcSqlComando)
    If lcCursorEnvio.RowCount < 1 Then
        Msgbox("NO se encuentra un ENVIO cargado","Impresion de Envio")
        Return       
    End If
    '
    lcSqlComando    = "SELECT * FROM work_t_envios_detalle ORDER BY wsdescripcion"
    lcCursorDetalle    = Starter.Database.ExecQuery(lcSqlComando)
    If lcCursorDetalle.RowCount < 1 Then
        Msgbox("EL Envio NO tiene productos cargados","Impresion de Envio")
        Return
    End If
    '
    lcCursorEnvio.Position    = 0
    '
    lcSqlComando    = ""
    lcData            = ""
    lcFecha            = ""
    lcHora            = ""
    lcStr            = ""
    '
    If lcCursorEnvio.GetString("moneda_impresion") = "S" Then
        lcMoneda        = "$ "
        lcTasaImpresion    = Starter.ParTasaDolares
    Else
        lcMoneda        = "Q "
        lcTasaImpresion    = 1.00
    End If
    '
    ' Imprime el Envio que está CARGADO en "work_t_envios"
    '
    lcLineasEnca    = Regex.Split(CRLF, Starter.SysDireccionEmpresa)
    lcLineFeed        = Chr(10)
    '
    ' Se asignan los SETS de la impresora
    Starter.o_Printer.Write(Starter.ParPrinterSets.GetBytes("UTF8"))
    Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    '
    ' Se imprime el 1er Encabezado
    Starter.o_Printer.Write(Starter.ParPNRHead01.GetBytes("UTF8"))
    Starter.o_Printer.Write(Str_Format_Center(Starter.SysNombreEmpresa.Trim,48).GetBytes("UTF8"))
    Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    '
    ' Se imprime el 2do Encabezado (direccion de la Empresa)
    For i = 0 To lcLineasEnca.Length - 1
        Starter.o_Printer.Write(Starter.ParPNRDet01.GetBytes("UTF8"))
        lcData    = lcLineasEnca(i).Trim
        lcData    = lcData.Replace(CRLF,"")
        Starter.o_Printer.Write(Str_Format_Center(lcData,48).GetBytes("UTF8"))
        Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    Next
    Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    '
    ' Se imprime el ENCABEZADO del Envio
    lcData    = ""
    Starter.o_Printer.Write(Starter.ParPNRHead02.GetBytes("UTF8"))
    lcData    = lcData & "ENVIO No: " & NumberFormat2(lcCursorEnvio.GetDouble("numero"),1,0,0,True)
    lcStr    = "Venta al " & lcCursorEnvio.GetString("tipo").Trim
    lcData    = lcData & Str_Repeat(" ", 47 - lcData.Length - lcStr.Length)
    lcData    = lcData & lcStr
    Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
    Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    '
    lcFecha    = lcCursorEnvio.GetString("fecha")
    lcFecha    = Change_Format_Date(lcFecha, "DD-MM-YYYY", "/")
    lcHora    = lcCursorEnvio.GetString("hora")
    '
    Starter.o_Printer.Write(Starter.ParPNRHead02.GetBytes("UTF8"))
    lcData            = "FECHA: " & lcFecha & "     HORA: " & lcHora
    Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
    Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    '
    Starter.o_Printer.Write(Starter.ParPNRHead02.GetBytes("UTF8"))
    lcData    = "CLIENTE: (" & lcCursorEnvio.GetString("fk_cliente") & ") " & lcCursorEnvio.GetString("wsclbnombrecliente").Trim
    Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
    Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    '
    ' Se imprime el Detalle del Envio (productos)
    Starter.o_Printer.Write(Starter.ParPNRHead02.GetBytes("UTF8"))
    Starter.o_Printer.Write(Str_Repeat("-",48).GetBytes("UTF8"))
    Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    Starter.o_Printer.Write(Starter.ParPNRHead02.GetBytes("UTF8"))
    Starter.o_Printer.Write("PRODUCTO                    METROS        MONTO".GetBytes("UTF8"))
    '                         ....+....1....+....2....+....3....+....4....+...
    '                        ....+....1....+....2...... 999,999 9,999,999.99
    '                                                   ....+.. ....+....1..
    '                                                     TOTAL :
    Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    For i = 0 To lcCursorDetalle.RowCount -1
        lcCursorDetalle.Position    = i
        lcData    = ""
        lcData    = lcCursorDetalle.GetString("wsdescripcion").Trim
        lcData    = lcData & Str_Repeat(" ", 25 - lcData.Length)
        lcData    = lcData & Str_Format_Right(NumberFormat2(lcCursorDetalle.GetDouble("cantidad"),1,1,1,False),7)
        lcData    = lcData & Str_Format_Right(lcMoneda & NumberFormat2(lcCursorDetalle.GetDouble("total")/lcTasaImpresion,1,2,2,True),15)
        '
        Starter.o_Printer.Write(Starter.ParPNRDet01.GetBytes("UTF8"))
        Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
        Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    Next
    '
    ' Se imprime el total del envio
    Starter.o_Printer.Write(Starter.ParPNRDet01.GetBytes("UTF8"))
    Starter.o_Printer.Write(Str_Format_Right("-------------",48).GetBytes("UTF8"))
    Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    lcData    = Str_Format_Right("TOTAL :" ,32) & Str_Format_Right(lcMoneda & NumberFormat2(lcCursorEnvio.GetDouble("total")/lcTasaImpresion,1,2,2,True),15)
    Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
    Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    '
    ' Se imprime la información adicional del Envio
    Starter.o_Printer.Write(Starter.ParPNRDet01.GetBytes("UTF8"))
    lcData    = "Destino: " & lcCursorEnvio.GetString("destino").Trim
    Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
    Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    '
    Starter.o_Printer.Write(Starter.ParPNRDet01.GetBytes("UTF8"))
    lcData    = "Piloto: " & lcCursorEnvio.GetString("piloto").Trim
    Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
    Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    '
    Starter.o_Printer.Write(Starter.ParPNRDet01.GetBytes("UTF8"))
    lcData    = "Placas: " & lcCursorEnvio.GetString("placas").Trim
    Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
    Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    '
    Starter.o_Printer.Write(Starter.ParPNRDet01.GetBytes("UTF8"))
    lcData    = "Observaciones: " & lcCursorEnvio.GetString("observaciones").Trim
    Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
    Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    '
    If lcCursorEnvio.GetString("tipo") = "Contado" Then
        Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
        Starter.o_Printer.Write(Starter.ParPNRDet01.GetBytes("UTF8"))
        lcData    = "No Recibo: " & lcCursorEnvio.GetString("recibo_numero").Trim
        Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
        Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    End If
    '
    Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    Starter.o_Printer.Write(Starter.ParPNRHead02.GetBytes("UTF8"))
    lcData    = "Le atendió: (" & Starter.SysCodigoCobrador & ") " & Starter.SysNombreUsuario.ToUpperCase
    Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
    Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    '
    If lcCursorEnvio.GetDouble("total_descuento") > 0 Then
        Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
        Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
        Starter.o_Printer.Write(Starter.ParPNRDet01.GetBytes("UTF8"))
        Starter.o_Printer.Write(Str_Repeat("-",48).GetBytes("UTF8"))
        Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
        lcData    = "  Credito a cuenta :" & Str_Format_Right(lcMoneda & NumberFormat2(lcCursorEnvio.GetDouble("total_descuento")/lcTasaImpresion,1,2,2,True),13)
        Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
        Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
        lcData    = "   Saldo del Envio :" & Str_Format_Right(lcMoneda & NumberFormat2(lcCursorEnvio.GetDouble("valor_contable")/lcTasaImpresion,1,2,2,True),13)
        Starter.o_Printer.Write(lcData.GetBytes("UTF8"))
        Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
        Starter.o_Printer.Write(Str_Repeat("-",48).GetBytes("UTF8"))
        Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    End If
    '
    ' Se imprimen lineas en blanco para el Corte del Papel
    For i = 1 To Starter.ParPNRNumLf
        Starter.o_Printer.Write(lcLineFeed.GetBytes("UTF8"))
    Next
    '
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…