Android Question Bluetooth Zebra printers

Gianluca Esposito

Member
Licensed User
Longtime User
hi thank's for support.
I developed an app that manages SQLite database . I simply have to print the result of a query to a printer connected via bluetooth .
Which way would you recommend?

Thanks
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Gianluca Esposito

Member
Licensed User
Longtime User
Thanks for the support. I should just print text from an application that records data. It seems to be a complicated thing so much that we plan to change the printer.
Gianluca
 
Upvote 0

edgar_ortiz

Active Member
Licensed User
Longtime User
I hope it is useful for you
B4X:
'
' In Starter Service
'
    Dim o_Serial                        As Serial        ' Objeto que contiene la comunicacion con los dispositivos
    Dim o_Printer                        As TextWriter    ' Objeto que contiene la informacion a imprimir
    Dim o_Printer_Conected                As Boolean        ' Indica si la impresora está conectada
'
' In an activity, the user selects the printer to use from the bluetooth devices
'
Sub Activity_Create(FirstTime As Boolean)
    '
    ' Se carga la Actividad
    Activity.LoadLayout("ConnectPrinter")
    '
    If Starter.ParPrinterAddress <> "" Then
        lcPrinterName        = Starter.ParPrinterName
        lcPrinterAddress    = Starter.ParPrinterAddress
        '
        If Starter.o_Printer.IsInitialized = True Then
            Starter.o_Serial.Connect(lcPrinterAddress) 'convert the name to mac address
        End If
    End If
End Sub
'
Sub cibutConectar_Click
    Dim PairedDevices        As Map
    '
    PairedDevices = Starter.o_Serial.GetPairedDevices
    Dim l As List
    l.Initialize
    For i = 0 To PairedDevices.Size - 1
        lcPrinterName    = PairedDevices.GetKeyAt(i)
        l.Add(lcPrinterName)
    Next
    '
    Dim res As Int
    res = InputList(l, "Seleccione la Impresora", -1) 'show list with paired devices
    If res <> DialogResponse.CANCEL Then
        lcPrinterAddress    = PairedDevices.Get(l.Get(res))
        lcPrinterName        = l.Get(res)
        Msgbox("Conectarse a: " & l.Get(res), lcPrinterAddress)
        Starter.o_Serial.Connect(lcPrinterAddress) 'convert the name to mac address
    End If

End Sub
'
Sub o_Serial_Connected (Success As Boolean)
    '
    If Success Then
        ToastMessageShow("Impresora CONECTADA!!", False)
        ' TextWriter1.Initialize(Serial1.OutputStream)
        Starter.o_Printer.Initialize2(Starter.o_Serial.OutputStream, "ISO-8859-1")
        'Main.o_Printer.Initialize(Main.o_Serial.OutputStream)
        Starter.o_Printer_Conected    = True
        Starter.ParPrinterName        = lcPrinterName
        Starter.ParPrinterAddress    = lcPrinterAddress
        '
        Rutinas.Update_DB_Parametro ("SYS_IMPRESION_ACTIVA", "S")
        Rutinas.Update_DB_Parametro ("PRINTER_NAME", Starter.ParPrinterName)
        Rutinas.Update_DB_Parametro ("PRINTER_ADDRESS", Starter.ParPrinterAddress)
        '
        Starter.o_Printer.WriteLine(Starter.ParPrinterSets)
        Starter.o_Printer.Flush
        '
        Msgbox("Impresora Conectada",Activity.Title)
        Activity.Finish
    Else
        Starter.o_Printer_Conected    = False
        Log("Error conectando : " & LastException.Message )
        Msgbox(LastException.Message, "Error conectando")
        Starter.ParPrinterName        = ""
        Starter.ParPrinterAddress    = ""
    End If
End Sub
'
' Printing
'
Sub Imprime_Lectura
    Dim lcLineasEnca()    As String
    Dim lcLineFeed        As String
    '
    ' 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
    '
    '
    lcLineasEnca    = Regex.Split(CRLF, Starter.SysDireccionEmpresa)
    lcLineFeed        = Chr(10)
    '
    ' Se asignan los SETS de la impresora
    Starter.o_Printer.Write(Starter.ParPrinterSets)
    Starter.o_Printer.Write(lcLineFeed)
    '
    ' Se imprime el 1er Encabezado
    Starter.o_Printer.Write(Starter.ParPNRHead01)
    Starter.o_Printer.Write(Str_Format_Center(Starter.SysNombreEmpresa.Trim,48))
    Starter.o_Printer.Write(lcLineFeed)
    '
    ' Se imprime el 2do Encabezado (direccion de la Empresa)
    For i = 0 To lcLineasEnca.Length - 1
        Starter.o_Printer.Write(Starter.ParPNRDet01)
        lcData    = lcLineasEnca(i).Trim
        lcData    = lcData.Replace(CRLF,"")
        Starter.o_Printer.Write(Str_Format_Center(lcData,48))
        Starter.o_Printer.Write(lcLineFeed)
    Next
    Starter.o_Printer.Write(lcLineFeed)
    '
    '
    ' Se imprimen lineas en blanco para el Corte del Papel
    For i = 1 To Starter.ParPNRNumLf
        Starter.o_Printer.Write(lcLineFeed)
    Next
    '
    Starter.o_Printer.Flush

End Sub
 
Upvote 0

yejian503

Member
Licensed User
Longtime User
Examples (BARCODE-1D.LBL):
! 0 200 200 1000 1<CR><LF>
JOURNAL<CR><LF>
BT 7 0 2<CR><LF>
BARCODE 128 1 2 20 25 0 12345<CR><LF>
T 7 0 300 0 Code 128<CR><LF>
BARCODE 39 1 2 20 25 50 12345<CR><LF>
T 7 0 300 50 Code 39<CR><LF>
BARCODE 93 1 2 20 25 100 12345<CR><LF>
T 7 0 300 100 Code 93<CR><LF>
BARCODE CODABAR 1 2 20 25 150 A12345B<CR><LF>
T 7 0 300 150 CodaBar<CR><LF>
BARCODE EAN13 1 2 20 25 200 123456789012<CR><LF>
T 7 0 300 200 EAN13<CR><LF>
BARCODE EAN8 1 2 20 25 250 01234567<CR><LF>
T 7 0 300 250 EAN8<CR><LF>
BARCODE FIM 1 2 20 25 300 A<CR><LF>
T 7 0 300 300 FIM<CR><LF>
BARCODE I2OF5 1 2 20 25 350 12345<CR><LF>
T 7 0 300 350 I2 of 5<CR><LF>
BARCODE MSI 1 2 20 25 400 12345<CR><LF>
T 7 0 300 400 MSI<CR><LF>
BARCODE POSTNET 1 2 20 25 450 12345<CR><LF>
T 7 0 300 450 PostNet<CR><LF>
BARCODE UPCA 1 2 20 25 500 123456789012<CR><LF>
T 7 0 300 500 UPC-A<CR><LF>
BARCODE UPCE 1 2 20 25 550 1234567<CR><LF>
T 7 0 300 550 UPC-E<CR><LF>
BARCODE UPCE5 1 2 20 25 600 1234567 12345<CR><LF>
T 7 0 300 600 UPC-E Plus 5<CR><LF>
BARCODE F39 1 2 20 25 650 a<135>c<CR><LF>
T 7 0 300 650 Full Code 39<CR><LF>
PRINT<CR><LF>

This is the official documentation
 
Upvote 0
Top