Android Question Impresion Bluetooth

Manuel Eras Larios

Member
Licensed User
Longtime User
Saludos, NECESITO Ayuda al enviar a imprimir via bluetooth, en ocaciones la impresion sale en desorden, por ejemplo, si quiero imprimir asI
linea 1
linea 2
linea 3
a veces sale
linea 3
linea 2
linea 1
ó
linea 2
linea 1
linea 3
 

DonManfred

Expert
Licensed User
Longtime User
This is the english part of the forum. Please write english here or write the thread in the forum part for your language
 
Upvote 0

Manuel Eras Larios

Member
Licensed User
Longtime User
Greetings, I need help to send to print via Bluetooth, on occasion the print out of order, for example, if I want to print well
line 1
line 2
line 3

sometimes out

line 3
line 2
line 1

or

line 2
line 1
line 3
 
Upvote 0

Manuel Eras Larios

Member
Licensed User
Longtime User
Printer is Zebra MZ320. the tablet Samsung Galaxy Tab3, the code is:

Sub Process_Globals
PrintBuffer AsString
Dim btAdmin AsBluetoothAdmin
Dim cmp20 AsSerial
Dim printer AsTextWriter
End Sub


Sub Globals
Dim Toggla AsToggle
Dim btnImprimir AsButton
End Sub

Sub btnImprimir_Click
Imprimir
End Sub

Sub Imprimir
Toggla.TurnBluetoothOn

btAdmin.Initialize("BlueTooth")
cmp20.Initialize("Printer")

StartPrinter
End Sub


Sub Printer_Connected (Success AsBoolean)
If Success Then
ImprimirDatos
Else
If Msgbox2("", "Error de Impresora ","ReImprimir","Cancelar","",Null) = DialogResponse.POSITIVE Then
StartPrinter
EndIf
EndIf
EndSub

Sub StartPrinter
Dim PairedDevices AsMap
Dim L AsList
Dim Res AsInt

ToastMessageShow("Imprimiendo ...",True)

PairedDevices.Initialize

Try
PairedDevices = cmp20.GetPairedDevices
Catch
Msgbox("Emparejando con la impresora ...","Error de Impresora")
printer.Close
cmp20.Disconnect
EndTry


If PairedDevices.Size = 0Then
Msgbox("Error Conectando con la impresora - No encontrada ...","")
Return
EndIf

If PairedDevices.Size = 1Then
Try
cmp20.ConnectInsecure(btAdmin,PairedDevices.Get(PairedDevices.GetKeyAt(0)),1)
Catch
Msgbox("Conectando ...","Error de Impresora")
printer.Close
cmp20.Disconnect
EndTry

Else

L.Initialize

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

Res = InputList(L, "Seleccione un Dispositivo", -1)
If Res <> DialogResponse.CANCEL Then

cmp20.Connect(PairedDevices.Get(L.Get(Res)))

EndIf

EndIf

EndSub


Sub ImprimirDatos
printer.Initialize(cmp20.OutputStream)

PrintBuffer = Chr(13) & Chr(10)
printer.Write(PrintBuffer)
printer.Flush

PrintBuffer = Chr(13) & Chr(10)
printer.Write(PrintBuffer)
printer.Flush

PrintBuffer = “line 1” & Chr(13) & Chr(10)
printer.Flush
PrintBuffer = “line 2” & Chr(13) & Chr(10)
printer.Flush
PrintBuffer = “line 3” & Chr(13) & Chr(10)
printer.Flush

printBuffer = ""

Msgbox("Impresión finalizada!","")

printer.Close
cmp20.Disconnect
End Sub
 
Upvote 0

Manuel Eras Larios

Member
Licensed User
Longtime User
Printer is Zebra MZ320. the tablet Samsung Galaxy Tab3, the code is:

Sub Process_Globals
PrintBuffer AsString
Dim btAdmin AsBluetoothAdmin
Dim cmp20 AsSerial
Dim printer AsTextWriter
End Sub


Sub Globals
Dim Toggla AsToggle
Dim btnImprimir AsButton
End Sub

Sub btnImprimir_Click
Imprimir
End Sub

Sub Imprimir
Toggla.TurnBluetoothOn

btAdmin.Initialize("BlueTooth")
cmp20.Initialize("Printer")

StartPrinter
End Sub


Sub Printer_Connected (Success AsBoolean)
If Success Then
ImprimirDatos
Else
If Msgbox2("", "Error de Impresora ","ReImprimir","Cancelar","",Null) = DialogResponse.POSITIVE Then
StartPrinter
EndIf
EndIf
EndSub

Sub StartPrinter
Dim PairedDevices AsMap
Dim L AsList
Dim Res AsInt

ToastMessageShow("Imprimiendo ...",True)

PairedDevices.Initialize

Try
PairedDevices = cmp20.GetPairedDevices
Catch
Msgbox("Emparejando con la impresora ...","Error de Impresora")
printer.Close
cmp20.Disconnect
EndTry


If PairedDevices.Size = 0Then
Msgbox("Error Conectando con la impresora - No encontrada ...","")
Return
EndIf

If PairedDevices.Size = 1Then
Try
cmp20.ConnectInsecure(btAdmin,PairedDevices.Get(PairedDevices.GetKeyAt(0)),1)
Catch
Msgbox("Conectando ...","Error de Impresora")
printer.Close
cmp20.Disconnect
EndTry

Else

L.Initialize

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

Res = InputList(L, "Seleccione un Dispositivo", -1)
If Res <> DialogResponse.CANCEL Then

cmp20.Connect(PairedDevices.Get(L.Get(Res)))

EndIf

EndIf

EndSub


Sub ImprimirDatos
printer.Initialize(cmp20.OutputStream)

PrintBuffer = Chr(13) & Chr(10)
printer.Write(PrintBuffer)
printer.Flush

PrintBuffer = Chr(13) & Chr(10)
printer.Write(PrintBuffer)
printer.Flush

PrintBuffer = “line 1” & Chr(13) & Chr(10)
printer.Write(PrintBuffer)
printer.Flush
PrintBuffer = “line 2” & Chr(13) & Chr(10)
printer.Write(PrintBuffer)
printer.Flush
PrintBuffer = “line 3” & Chr(13) & Chr(10)
printer.Write(PrintBuffer)
printer.Flush

printBuffer = ""

Msgbox("Impresión finalizada!","")

printer.Close
cmp20.Disconnect
End Sub
 
Upvote 0
Top