I have trouble printing with an integrated mobile point of sale printer. I have attached the image of the printer.
My code works well with bluetooth printer but with the integrated printer does not work.
My code is as follows
My code works well with bluetooth printer but with the integrated printer does not work.
My code is as follows
B4X:
Public Sub DirectPrint(aPrinter As String, aData As String)
Dim PairedDevices As Map
Dim LocalBTMac As String
Dim LocalOSerial As Serial
Dim LocalPrinter As TextWriter
OSerial.Initialize("OSerial")
PairedDevices = OSerial.GetPairedDevices
For i = 0 To PairedDevices.Size - 1
Dim device As String = PairedDevices.GetKeyAt(i)
If device.Contains(aPrinter) Then
LocalBTMac = PairedDevices.get(device)
LocalOSerial.Initialize("DirectPrint")
LocalOSerial.Connect(LocalBTMac)
Wait For DirectPrint_Connected (Success As Boolean)
If Success Then
' LocalPrinter.Initialize(LocalOSerial.OutputStream)
LocalPrinter.Initialize2(LocalOSerial.OutputStream,"windows-1252") 'important
LocalPrinter.WriteLine(aData)
LocalPrinter.Flush
LocalPrinter.Close
LocalOSerial.Disconnect
End If
End If
Next
End Sub