Android Question How to print text in graphic mode?

vecino

Well-Known Member
Licensed User
Longtime User
Hi, a customer has some portable bluetooth printers that only print English and Chinese characters.

I need to print these characters:
á é í ó ú Á É Í Ó Ú ñ Ñ ç Ç €

The printers are ESC/POS compatible, but the characters are "cut out" in all the codepages and there are no characters from other languages.

I made a question to the manufacturer and he has indicated that I must use the graphic mode to get these characters to print.
Can anyone explain to me how to do this?
Thank you very much.
 
Last edited:

vecino

Well-Known Member
Licensed User
Longtime User
or maybe just
B4X:
Dim Label1 As B4XView
Dim bmp As B4XBitmap = Label1.Snapshot
Note: I never tested with Label as B4XView.
That's how it works :)
Although now I will have to adapt my software to print images when using this type of printer.

ok.jpg
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
No, it is not slow, it is not as fast as in text mode, but it is acceptable.
The bad thing is that I need several fonts for titles, totals, etc. and with a "Label" I can't change the fonts.

As for printing to PDF, the problem is that I have not yet been able to print anything because it does not give me to choose the bluetooth printer, it asks me for an IP.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
You can use custom fonts in B4A.

Which library you are using?
After generating a "PDF" I try to print it, a program on the tablet opens and asks me for the IP. In other words, it is independent of my program.
It's just a test to print a pdf.

¿Custom fonts?, on a label?
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Another option is to define characters that I don't need to print what I need, basically only: € ñ Ñ
The accented letters I can omit them, for the moment.
But does anyone have a link on how to define characters?
ESC & 0 n1 n2d0d1d2 data

Allows the user to define their own characters.
N1= Number of the first character
n2= Number of the last character
d0= Space to the left of the character
d1= Width of the character
d2= Space to the right of the character
data = 3 bytes needed for each character
character; superscript/subscript need only
2 bytes per character
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
I am looking for B4A snippets or examples, which works on bt thermal printer.
And this class is not going to serve you or is it a special case?
in the forum there are solutions that you can look for.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
And this class is not going to serve you or is it a special case?
in the forum there are solutions that you can look for.
Thanks. I thought there is a way to print the PDF straight away. It's okay. This is a solution.
 
Upvote 0

emexes

Expert
Licensed User
These are the characters available in text mode:

aToacVA.jpg

What happens if you print this test again, after printing/sending possible control code to select Windows 1252 character set eg something like:

B4X:
Dim TestString As String
For I = 33 to 255
    TestString = TestString & Chr(I)
Next
TestString = TestString & Chr(13) & Chr(10)

Dim Windows1252 As String = Chr(27) & Chr(116) & Chr(14)

SendToPrinter(TestString)
SendToPrinter(Windows1252)
SendToPrinter(TestString)
 
Last edited:
Upvote 0

emexes

Expert
Licensed User
What happens if you print this test again, after printing/sending possible control code to select Windows 1252 character set eg something like:

Actually it would be even better to do the test string in lines of 32 characters, eg:

B4X:
Dim TestString As String
For FirstCharOnLine = 32 To 255 Step 32
    For I = FirstCharOnLine To FirstCharOnLine + 31
        TestString = TestString & Chr(I)
    Next
    TestString = TestString & Chr(13) & Chr(10)
Next
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
What happens if you print this test again, after printing/sending possible control code to select Windows 1252 character set eg something like:

B4X:
Dim TestString As String
For I = 33 to 255
    TestString = TestString & Chr(I)
Next
TestString = TestString & Chr(13) & Chr(10)

Dim Windows1252 As String = Chr(27) & Chr(116) & Chr(14)

SendToPrinter(TestString)
SendToPrinter(Windows1252)
SendToPrinter(TestString)

aaa.jpg
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
To get those characters into a Chinese printer you need to change the CharSet Encoding and possibly the codePage.

With my library I would do this to see which CharSet contains those characters:
B4X:
For Each EC As String In Array As String("Cp1025","GB18030","GB2312","windows-1250","windows-1251","windows-1252","windows-1253","windows-1254","windows-1257")
    Log(EC)
    Printer.CharSet=EC
    Printer.AddBuffer_WriteLine(EC)
    Printer.AddBuffer_WriteLine("á é í ó ú Á É Í Ó Ú ñ Ñ ç Ç €")
Next
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Hi, I am testing with this one:
Do you think I can adapt it?

Ah, I think so, I'll give it a try.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
I think so
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Well, here is the proof you have indicated.
You see lowercase accented vowels and the euro symbol.
The accented uppercase vowels and the ñÑ are not there.

000.jpg
 
Upvote 0
Top