B4A Class Bluetooth ESC/POS Printer Class

vvg

Member
Licensed User
Longtime User
Best solution. I got here what I wanted.
But agraham, if you can will you please
provide USB printing code in the class?
 

Unobtainius

Active Member
Licensed User
Longtime User
Thank you very much for such a great library, a small donation made. I didn't see the suggested amount before making it so there's an extra coffee in it for you
 

Valerio Minnella

Member
Licensed User
Hi Agraham.
I have integrated your code (many thanks) in my application and it works very well, but if I try to print a .png image it does not print anything or a black square.
With .jpg files it's perfect, but I have to use .png and I can't.

Any suggestion?
 

Oswaldo Sanchez

New Member
Licensed User
Longtime User


Hello i can print QR Barcode but barcode is never decoded, why this happen?
 

agraham

Expert
Licensed User
Longtime User
Hello i can print QR Barcode but barcode is never decoded, why this happen?
Probably because, just like mine, your cheap Chinese printer is crap.
 

scsjc

Well-Known Member
Licensed User
Longtime User
Awesome job it works super well congratulations

B4X:
Public Sub FlushClose
    Astream.SendAllAndClose
End Sub

I recommend adding this sub to the class, to be able to close and fire the event "AStream_Terminated" (because it never fires)
Can be called as Printer1.FlushClose
 

Ertan

Active Member
Licensed User
Hello,
It doesn't print all Turkish characters. Only ( ç , ü , ö , Ü , Ö , Ç ) printing these characters.

" ı, ğ, ş, İ, Ğ, Ş, " I want to print these letters. I've been researching for this for a few months but I couldn't figure it out.

Can you help me to solve this event?

" ı, ğ, ş, İ, Ğ, Ş, "

1. İrem
2. Oğlan
3. OĞLAN
4. Şile
5. şile

I couldn't print the underlined letters. How can we solve this?

 

Ertan

Active Member
Licensed User

emexes

Expert
Licensed User
I have been dealing with this for 3 months ..
Ouch. But I admire your tenacity, so I'll join you in the quest. I think worst case is that you might have to print text to a bitmap/image, and then print that. Mildly tedious, but quite doable.

 

emexes

Expert
Licensed User
This search suggests that code page 857 is the only code page that contains the characters you want to print:

 

emexes

Expert
Licensed User
Can this help in printer settings?
Does a bear sh*t in the woods?!?!

Translation: you might have found the solution. Activate that setting, and then try printing Chr(166) & Chr(167) & Chr(168) to the printer.

Might not work first go, because if you are sending as UTF then those characters will be transformed into multi-byte sequences. But worth a go, sometimes things are simpler than expected.
 

emexes

Expert
Licensed User
" P61 "Can this help in printer settings?
I found this in a manual for a similar printer.

Also, could you please show me a fragment of your code that sends text to the printer. Eg are you sending strings or bytes? What happens when you send those extended characters Chr(166) & Chr(167) & Chr(168) to the printer? What characters does it print? (from that, we can probably work out what code page it is currently using, which is a useful starting point)

 

Ertan

Active Member
Licensed User
B4X:
Printer1.WriteString(Chr(166) & Chr(167) & Chr(168))
I'm trying to send it this way, right? but it doesn't print.
Or will you guide me how to do otherwise?
 
Last edited:

emexes

Expert
Licensed User
B4X:
Printer1.WriteString(Chr(166) & Chr(167) & Chr(168))
I'm trying to send it this way, right?
Or will you guide me how to do otherwise?
That looks good. The sample in the photograph, presumably you printed that with:
B4X:
Printer1.WriteString("İrem")
Printer1.WriteString("Oğlan")
Printer1.WriteString("OĞLAN")
Printer1.WriteString("Şile")
Printer1.WriteString("şile")
Does WriteString automatically add CRLF to move to the next line, or do you have to add it "manually" eg:
B4X:
Printer1.WriteString("İrem" & CRLF)    'CRLF is actually only LF
Printer1.WriteString("İrem" & Chr(13) & Chr(10))    'CR = ASCII 13, LF = ASCII 10

 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…