Android Question Can the "Printing" library be used to print via Bluetooth?

vecino

Well-Known Member
Licensed User
Longtime User
Hello, that's my doubt, I've been testing but I haven't found any example.
I am referring to this library.
Thank you.
 

MicroDrie

Well-Known Member
Licensed User
then when you send any text string the printer does nothing
Can you publish the program code how to send something to the printer?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Have you read the update by Erel about SDK >= 31?

 
Upvote 0

amorosik

Expert
Licensed User
Have you read the update by Erel about SDK >= 31?


This example does not find any devices
After pressing Scan&Connect it does not find any devices
 
Upvote 0

amorosik

Expert
Licensed User
Can you publish the program code how to send something to the printer?

The Agraham example
Printer is 'connected succefully', but when you click on TEXT or BARCODE or other key button, nothing appear on printer

B4X:
Sub Process_Globals
    Dim Printer1 As EscPosPrinter
    Dim Version As Double = 2.0 ' Demo program version
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Main")
    Activity.AddMenuItem("Connect", "mnuConnect")
    Activity.AddMenuItem("Disconnect", "mnuDisconnect")
    If FirstTime Then
        Printer1.Initialize(Me, "Printer1") 
        DisableButtons 
    End If
    Activity.Title = Activity.Title & " v" & NumberFormat2(Version, 0, 1, 1, False)
End Sub

Sub Printer1_Connected (Success As Boolean)
    If Success Then
        ToastMessageShow("Connected successfully", False)
        EnableButtons
    Else
        Msgbox(Printer1.ConnectedErrorMsg, "Error connecting.")
    End If
End Sub


Sub btnText_Click
    Printer1.Reset
    Printer1.WriteString(Printer1.REVERSE)
    Printer1.WriteString("Reversed text" & CRLF)
    Printer1.WriteString(Printer1.UNREVERSE)
    Printer1.WriteString(Printer1.INVERT)
    Printer1.WriteString("Normal text £££ " & Chr(99) & CRLF)
    Printer1.WriteString(Printer1.UNINVERT)
    Printer1.WriteString(Printer1.ULINE1 & "Underline 1 " & Printer1.ULINE2 & "Underline 2 " & Printer1.ULINE0 & "Normal" & CRLF)
    Printer1.WriteString("None " & Printer1.BOLD & "Bold " & Printer1.NOBOLD & "None " & CRLF)
    Printer1.WriteString("Single " & Printer1.HIGH & "High " & Printer1.WIDE & "Wide " & Printer1.HIGHWIDE & "Both" & Printer1.SINGLE & CRLF)
    Printer1.LineSpacing = 15
    Printer1.WriteString("Line space half follows" & CRLF)
    Printer1.LineSpacing = 45
    Printer1.WriteString("Line space one and a half follows" & CRLF)
    Printer1.LineSpacing = 60
    Printer1.WriteString("Line space two follows" & CRLF)
    Printer1.WriteString("Ended" & CRLF)
  
    Printer1.LineSpacing = 20
    Printer1.CharacterFont = 0
    Printer1.WriteString("Character font = 0, inset line follows" & CRLF)
    Printer1.CharacterFont = 1
    Printer1.LeftInset = 100
    Printer1.WriteString("Character font = 1" & CRLF)
    Printer1.WriteString("Character font = 1, inset self-cancelled" & CRLF)
    Printer1.LeftMargin = 100
    Printer1.WriteString("Character font = 1, left margin set" & CRLF)
    Printer1.WriteString("Character font = 1" & CRLF)
    Printer1.WriteString("Character font = 1" & CRLF)
    Printer1.WriteString(Printer1.DEFAULTS)
    Dim tabs() As Int = Array As Int(8,16,24,32)
    Printer1.TabPositions = tabs
    Printer1.WriteString("The following numbers are tabbed across the line" & CRLF)
    Printer1.WriteString("0" & Printer1.HT & "1" & Printer1.HT & "2" & Printer1.HT & "3" & Printer1.HT & "4" & Printer1.HT & CRLF)
  
    Printer1.WriteString("0" & Printer1.HT & "1" & Printer1.HT & "2" & Printer1.HT & "3" & Printer1.HT & "4")
    Printer1.PrintAndFeedPaper(0) ' note no CRLF at end of line above
    Printer1.WriteString("0" & Printer1.HT & "1" & Printer1.HT & "2" & Printer1.HT & "3" & Printer1.HT & "4" & CRLF)
    Printer1.RelativePrintPosn = 120
    Printer1.WriteString("First")
    Printer1.RelativePrintPosn = 120 ' as dcoumented should push the next text further right but only works at start of line
    Printer1.WriteString("Second" & CRLF)
  
    Printer1.WriteString(Printer1.DEFAULTS & CRLF)
    Printer1.WriteString("Text ended" & CRLF & CRLF)
End Sub

Sub btnQrCode_Click
    ' On my printer small QR codes don't seem to be able to be decoded and larger ones look obviously wrong :(
    Printer1.Reset
    Printer1.HRIfont = 1
    Printer1.Justify = 1
    Printer1.WriteQRCode(0, "M", 6, "Thanks for using our thermal printer!")
    Printer1.WriteQRCode(0, "M", 4, "Thanks for using our thermal printer! Thanks for using our thermal printer! Thanks for using our thermal printer!")
End Sub
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
The Agraham example is a Bluetooth ESC/POS Printer Class driver and the paperang printer isn't an ESC/POS printer. It has a propriety non-published API whereby several people has reversed engineered the communication between the printer and the app. If I do understand well, first you have to pair the software with the printer, calqulate a custom CRC32, use a maximum packet length, number the packets and use a command number. Quite a bit of try and error work that cannot be developed and tested without a physical printer. And the question is how many people use this printer?
 
Upvote 0

amorosik

Expert
Licensed User
The Agraham example is a Bluetooth ESC/POS Printer Class driver and the paperang printer isn't an ESC/POS printer. It has a propriety non-published API whereby several people has reversed engineered the communication between the printer and the app. If I do understand well, first you have to pair the software with the printer, calqulate a custom CRC32, use a maximum packet length, number the packets and use a command number. Quite a bit of try and error work that cannot be developed and tested without a physical printer. And the question is how many people use this printer?

"..several people has reversed engineered..:"
Where have you read it?
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Where have you read it?
Here you will have to believe me 😇 because I also read a lot every day, can't bookmark everything and then have trouble getting anything back later. A typical Dutch disease (just like our Prime Minister has) is called selective memory loss.🤣😂🤣
 
Upvote 0
Top