Android Question Printing on Thermal Printer (58mm)

George_G

Member
Licensed User
Hello Everyone.

I am currently exploring the best way for printing on a thermal printer. I've been experimenting with "PrintHtml," but I've noticed that the print quality is not good.

Could anyone offer any suggestions or recommendations for achieving higher quality prints on a thermal printer?


Thanks in advance.
 

agraham

Expert
Licensed User
Longtime User
This is my class for printing om a Bluetooth connected thermal printer, but there is little you can do to improve the print quality which is really determined only by the printer itself and the quality of the paper used.

 
Upvote 1

George_G

Member
Licensed User
This is my class for printing om a Bluetooth connected thermal printer, but there is little you can do to improve the print quality which is really determined only by the printer itself and the quality of the paper used.

Thank you for your reply.
Is there any way to print greek characters ?
or it depends on printer settings?
 
Upvote 0

Lucas Siqueira

Active Member
Licensed User
Longtime User
@nwhitfield published a sensational example of POS that integrates with ESC/POS Bluetooth printers

 
Upvote 0

Lucas Siqueira

Active Member
Licensed User
Longtime User


 
Upvote 0

George_G

Member
Licensed User
@nwhitfield published a sensational example of POS that integrates with ESC/POS Bluetooth printers

Is there any way to print on the selected printer directly?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
To check whether the printer can print Greek, you need to check the description of the printer model from the manufacturer website or seller e-commerce portal such as datasheet or brochure.
Usually the thing you need to check are the supported Code Page and International Character Set.
 
Upvote 0

George_G

Member
Licensed User
To check whether the printer can print Greek, you need to check the description of the printer model from the manufacturer website or seller e-commerce portal such as datasheet or brochure.
Usually the thing you need to check are the supported Code Page and International Character Set.
I am trying to find the suitable codepage for EscPosPrinter, to print greek.
Do you know where could I find it?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
1. Try print SelfTest. By pressing Linefeed while turning on the printer. It will print the supported features of the printer.
2. Get the document from the manufacturer website.
3. Google "ESC/POS Code Page Greek"

From this link:

The code page maybe: PC737, PC851, PC869 or PC928.
 
Upvote 0

George_G

Member
Licensed User
You can put a Label on a Panel (declare as B4XView) or just declare the label as B4XView. Set the Label's Text. Panel.Snapshot returns as B4XBitmap. You have to convert it to AnImage type then use PrintImage method of the printer class posted in post #2.
Thank you.
Do you have any advice for the size of the bitmap?(because of the thermal printer)
 
Upvote 0

George_G

Member
Licensed User
I have a problem while I am printing.

I used this example.

I create my receipt on this one. And the printing was good. (the b-pos app is landscape)

I copied the code, on my program and I get a very bad printing. (my app is portrait)

The code is the following

B4X:
Sub btnImage_Click
    Printer1.Reset
    Dim cs As CSBuilder
    cs.Initialize.Size(7).Alignment("ALIGN_LEFT").Append("ΦΟΡΟΛΟΓΙΚΗ - ΑΠΟΔΕΙΞΗ ΕΝΑΡΞΗ" & CRLF).Pop
    cs.Size(10).Alignment("ALIGN_CENTER").Append("ΦΟΡΟΛΟΓΙΚΗ - ΑΠΟΔΕΙΞΗ ΛΗΞΗ" & CRLF).Pop
    cs.Size(10).Alignment("ALIGN_NORMAL").Append("ΦΟΡΟΛΟΓΙΚΗ - ΑΠΟΔΕΙΞΗ ΛΗΞΗ" & CRLF).Pop
    cs.Size(10).Alignment("ALIGN_OPPOSITE").Append("ΦΟΡΟΛΟΓΙΚΗ - ΑΠΟΔΕΙΞΗ ΛΗΞΗ" & CRLF).Pop
    cs.Size(10).Alignment("ALIGN_CENTER").Append("ΦΟΡΟΛΟΓΙΚΗ - ΑΠΟΔΕΙΞΗ ΛΗΞΗ" & CRLF).Pop
    cs.Size(10).Append("ΤΕΣΤ αποδειξη"& CRLF).Pop
    cs.Size(10).Append("ΕΙΔΟΣ ΤΕΣΤ"& CRLF).Pop
    cs.Size(10).Append("ΤΕΜΑΧΙΟ 1"& CRLF)
    cs.PopAll
        
    lblGreek.Text = cs
        
    Dim Out As OutputStream
    Out = File.OpenOutput(File.DirInternal, "Test.png", False)
    pnlGreek.Snapshot.WriteToStream(Out, 100, "PNG")
    Out.Close
                
                
    Dim bmp As Bitmap

    If File.Exists(File.DirInternal,"Test.png") Then
        bmp.Initialize(File.DirInternal,"Test.png")
    Else
        Return
    End If
    
    
    ' Convert the RGB image to one with luminance values
    Dim myimage As AnImage = Printer1.ImageToBWIMage(bmp)
    
    ' Choose thresholding the image or dithering it to get a black and white bit image
    myimage = Printer1.ThresholdImage(myimage, 128)
    
    ' Send the black and white bit image to the printer
    myimage= Printer1.PackImage(myimage)
    Printer1.WriteString(CRLF) ' nudge the printer to show the user something is happening
    Printer1.PrintImage(myimage)
    Printer1.WriteString(CRLF & "Ended" & CRLF & CRLF)
End Sub

Any Idea?
 
Upvote 0
Top