Hi there!
I am using this class for some printers and works.
However I got a Sunmi T2 mini Android PDV and something weird is happening.
Using the Demo app suplied with the class, I can print normally on the innerprinter.
When trying the same class on my app it simply does not work. I have tried everything, changing encoding, adding a sleep(100), printing everything as one big string, printing lines. Tryed testing in debug, release.
When I copy and paste part of the example to my code (the part where there is "reversed text" in the demo, most of the times it works.
I prepare my printing (POS Receipt) from a local Rest Server. I have the option to send very basic text, no ESCPOS, and even with that no way.
I receive the data from the server as ENCODED, since it can have lots of escpos commands thata can eventually cause problem in the http parsing. I always decode to play text string.
I can expect that before printing and seems normal text.
Then I started to break down the text in line and send one by one and that does not work either.
Sub DecodePrint(dStr As String) As String
If FAppManager.Server.ReportedAPI > 16 Then
Try
Dim su As StringUtils
Dim Decoded() As Byte = su.DecodeBase64(dStr)
Dim str As String = BytesToString(Decoded, 0, Decoded.Length, "UTF-8")
Return str
Catch
Log(LastException.Message)
Return dStr
End Try
Else
Return dStr
End If
End Sub
private Sub PrintLocalLIB(aStr As String, Param As TPrintParam)
If FPrinter.IsInitialized Then
Dim str As String = DecodePrint(aStr)
If str <> "" Then
FPrinter.Reset
Dim Direto As Boolean = Param.Direto
If (Param.DiretoFiltro <> "") And (Param.DiretoFiltro <> Null) Then
If str.Contains(Param.DiretoFiltro) Then
Direto = True
End If
End If
If Direto Then
FPrinter.WriteString(str)
Else
ToastMessageShow("Aguarde Impressão", False)
' FPrinter.CharacterFont = 0
' FPrinter.LineSpacing = 15
Dim paramnum () As String = Regex.Split(Chr(10), str)
For Each n As String In paramnum
Dim Line As String = n.Replace(Chr(10), "").Replace(Chr(13), "")
If Param.RemoverLinhas And Line = "" Then
Else
If Param.CortarEsquerda > 0 Then
If Line.Length <= Param.CortarEsquerda Then
Line = ""
Else
Line = Line.SubString2(Param.CortarEsquerda, Line.Length)
End If
End If
If Param.CortarDireita > 0 Then
If Line.Length <= Param.CortarDireita Then
Else
Line = Line.SubString2(0, Param.CortarDireita-1)
End If
End If
FPrinter.WriteString(Line&CRLF)
' FPrinter.WriteString(Line)
Sleep(50)
End If
Next
End If
End If
End If
End Sub
I have added that Sleep because in one android POS it was necessary to work, but removing it makes no difference.
Any ideas?