B4A Library SD: BT Printer Bluetooth

DonManfred

Expert
Licensed User
Longtime User
I updated the example at post # 1
Thank you. With this demos i can Print Text, Image and Mix.
Nice one. But unfortunately only a-zA-Z0-9. German "Umlauts" (äöüÄÖÜß) does not work with all three Encodings.

I´m pretty sure the problem is this f*** chinese Printer (grrr)...

But really nice library and examples! Good work.
 

Star-Dust

Expert
Licensed User
Longtime User
German characters can be set. Unfortunately, I do not have a bluetooth printer at the moment. I made the blind library (so to speak) but it works from 2017.

But next week I will get my first bluetooth printer. I will do some tests and add other functions not in mind including the one you need. And I also hope to make a version for IOS.
 

Star-Dust

Expert
Licensed User
Longtime User
Hi, what's the difference between sample1 and sample2?
No difference, I copied the same example twice.

However remember that for your printer my library is not good, because it is suitable for printed bluetooth, not dot matrix printers with bluetooth adapters.
A bluetooth receiver is not enough to make the bluetooth printer. In your case you need to develop a special library that transmits commands for the needle printer through the bluetooth.
 

vecino

Well-Known Member
Licensed User
Longtime User
Thanks, friend, I'm doing tests.
Then I comment on results.
 

DonManfred

Expert
Licensed User
Longtime User
To get german Umlauts working with my printer
B4X:
    ' Set Codepage to 6
    Printer.AddBuffer_ArrayByte(Array As Byte(0x1f,0x1b,0x1f,0xff,0x06))
    Printer.AddBuffer_Writeline("#0x06: äöüÄÖÜß")
    Printer.AddBuffer_Writeline("Umlaute Hähnchen, Brühe, Örtlichkeit, Süße ")
    Printer.AddBuffer_Writeline("äöüÄÖÜß")



B4X:
    ' Underline 2px thick
    Printer.AddBuffer_ArrayByte(Array As Byte(0x1b,0x2d,0x02))
    Printer.AddBuffer_Writeline("Underline 2 TEST - Mixed Text and Image")
    ' Underline 1px thick
    Printer.AddBuffer_ArrayByte(Array As Byte(0x1b,0x2d,0x01))
    Printer.AddBuffer_Writeline("Underline 1 TEST - Mixed Text and Image")
    ' Underline 0px thick (off)
    Printer.AddBuffer_ArrayByte(Array As Byte(0x1b,0x2d,0x00))
    Printer.AddBuffer_Writeline("Underline 0 TEST - Mixed Text and Image")
 

Star-Dust

Expert
Licensed User
Longtime User
Good job. Thank you for your suggestion
 

vvg

Member
Licensed User
Longtime User
Sir,
I have b4a Ver.8.50 & serial library Ver.1.31.
I tested your sample but while testing it in debug mode, it is throwing error & application stops. I have attached here the screenshot.
I observed that while executing line 72 i.e. "Printer.SearchNewPrinter", it gives error.
 

Attachments

  • Untitled.png
    134.5 KB · Views: 271

Star-Dust

Expert
Licensed User
Longtime User
Download the latest version of the library and try again. The problem should not arise
 

vvg

Member
Licensed User
Longtime User
Download the latest version of the library and try again. The problem should not arise
2
Ok. I tried. Now demo is working ok.
I will test it for my app and if any query will contact u..
Thanx
 

vecino

Well-Known Member
Licensed User
Longtime User

Hello, friend, really when putting an adapter, the printer will be bluetooth.
Another thing is to "get along" with the printer. But in this case it is compatible with epson esc/p, so there is no problem either.

Apparently the problem is not your library or other codes that I have tried. The problem is the tablet that I am using.
Finally I could do tests with other devices and all work well. (Always with this matrix printer and the adapter port serial 25 to bluetooth).

In the tablet that does not work, with Android 4.2 the problem is that it stays "locked" several seconds on each line it prints. This happens right in "Printer.flushAllAndClose".
In other codes that I have tried it happens in "Printer.Flush".
Other times, instead of "blocking", it shows the following message:
B4X:
main_imprimirtest (java line: 553)
java.io.IOException: [JSR82] write: write() failed.
   at android.bluetooth.BluetoothSocket.write(BluetoothSocket.java:702)
   at android.bluetooth.BluetoothOutputStream.write(BluetoothOutputStream.java:85)
   at java.io_OutputStreamWriter.flushBytes(OutputStreamWriter.java:167)
   at java.io_OutputStreamWriter.flush(OutputStreamWriter.java:158)
   at java.io.BufferedWriter.flush(BufferedWriter.java:124)
   at anywheresoftware.b4a.objects.streams.File$TextWriterWrapper.Flush(File.java:602)
I have only done some tests and they have worked well, but I have not been able to implement it in my software because they have ordered me something else that has more priority, so I had to "park" the theme of the printer again.
Thank you very much for your help.
Regards.
 

vvg

Member
Licensed User
Longtime User
2
Ok. I tried. Now demo is working ok.
I will test it for my app and if any query will contact u..
Thanx
Hi..sir, I want to give regional font printing at point of sale.

using Serial library gives printing in english text but not in regional font as bluetooth printer does not support.

So I thought that printing screenshot or lables (with regional font characters on it) will be better choice.

I also thought that using your library with xui will give desired result.

I tested your library. It is ok.

But I want to print image. I mean I want to use your library for pos receipt printing with regional fonts in which i will print label (or labels) of different sizes and with texts.

So with the support of xui library, I took snapshot of label on which i managed to fetch local font data from database and want that label to be printed as it is.... as an image... so that i could print receipt in regional font.

I tried this with your QR code. I replaced your QR code image with my label of same size. It printed not accurate.. but not bad.... It was OK.. with some distorted characters.

But when tried to print snapshot of different sizes, it printed garbage.

So what to do for printing of snapshot as it is.... or printing labels of different sizes on receipt?

My receipt, either it will be screenshot of activity or

it will be having different fields (lables)

whichever will be easier.....

Will you please guide me for this???
 

Star-Dust

Expert
Licensed User
Longtime User
Hi,
The images must be of a width space that does not exceed that of your printer, otherwise the commands are incorrectly translated and appear written in ASCII characters.

The images also do not have to be too big otherwise the bluetooth will not be able to transmit everything correctly. Then suggest images that represent one line of text at a time.

Unfortunately, you're trying to do something that has not been done by many at the moment, so you'll be the first to experiment.
 

vvg

Member
Licensed User
Longtime User
Sir,
My main concern is to print in indian language fonts with bluetooth printer.
Thats is why i am trying all this.
Because so far from what I understood, I can not do this with text printing as it only supporting english and those languages which are supported in printer code pages.
Here in 'stackoverflow' post in which i found the suggestion for what to do...
Here is the sugesstion.....
----
"Printers have predefined character sets built in. These character sets are known as code pages.

Your Bluetooth printer, like most POS printers doesn't seem to support Unicode.

To solve this you could try converting your output to an image and send it to the printer as bytes using an emulation the printer understands.(PCL, ESC/POS, ZPL etc.)"

But i do not know how to do...because i do not know java, bytes arrey concepts etc..

Sir, as I tested, your library is worth to purchase but if you give me this solution, many other indian b4a users will also be benefited.
Kindly include above said functionality in your library.
 

Star-Dust

Expert
Licensed User
Longtime User
I'm sorry at the moment I can not help you I'm making several libraries. On the other hand I'm creating the iOS version of this library and it's very complex because it uses BLE.

At the moment only you have this need, although it is achievable, it would take too much time and I have no request (apart from you), it is not advantageous for me to neglect other projects for this.
 

DonManfred

Expert
Licensed User
Longtime User
Sir, as I tested, your library is worth to purchase but if you give me this solution, many other indian b4a users will also be benefited.
Kindly include above said functionality in your library.
There is no need to add anything to the Library.
Use an Canvas to draw your text on and create a snapshot from the Canvas. Print this snapshotimage then.
You don´t need java knowledge for this. Just B4A.
If you are not able to do it then you should create a new thread in the Questionsforum about it.
 

Star-Dust

Expert
Licensed User
Longtime User
Already Erel has suggested him to use SnapShot views (Label) but fails.

So I suppose the problem can be more complex, also because for several weeks fighting on it ... maybe it needs something ready that I can not do
 

vvg

Member
Licensed User
Longtime User
Already Erel has suggested him to use SnapShot views (Label) but fails.

So I suppose the problem can be more complex, also because for several weeks fighting on it ... maybe it needs something ready that I can not do
 

vvg

Member
Licensed User
Longtime User
As suggested by many of you, don manfred, erel I successfully took Snapshot & image created.
But problem is about printing same image/lable on receipt.
I can not understand how to code to scale it so that it get printed well on my 58 mm Bluetooth printer?
 

vvg

Member
Licensed User
Longtime User
I drew text. Took snapshot.
Then i created png file of the snapshot and tried to print using bt printer library by star dust. But it printed garbage characters or dark strips..
Upto snapshot, i hv done already. But printing part i can not understand. I am trying till now also. But also searching for wellworking ready code/library ...ready to donate...because it is taking too much time and efforts as I am unclear about some basic printing concepts. So far I had developed desktop applications with vb6 and easy reporting tool like crystal reports. From crystal reports printing part was always been much easier.
So here I m facing problems.
If you have time to do this job, please tell me how much I hv to donate because stardust is saying he is busy in another project.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…