esc_pos_bluetooth icon indicating copy to clipboard operation
esc_pos_bluetooth copied to clipboard

Printing not smooth, it can't print with a large byte array

Open xfiremen opened this issue 5 years ago • 15 comments

I have tested on iOS with this printer. All functions worked well. https://www.craftdata.co.uk/thermal-printers/fk-pc301-d-3-mobile-thermal-printer-with-autocutter But it has some problems need to be improved. 1/ writeData method with big data, this device auto disconnect. 2/ Printing not smooth. Maybe you should support split byte data to more packets.

xfiremen avatar Mar 19 '20 06:03 xfiremen

Hi @xfiremen , Thank you for your feedback! What the size of your bytecode? Does it include any images? Could you provide your code, please?

andrey-ushakov avatar Mar 19 '20 08:03 andrey-ushakov

Hi @andrey-ushakov, I am tried on your demo. I removed all images. I try to multiple x10 times your receipt. ~ 14540 bytes.

New result: I have tried it with more printers. Some big printer work well. You should buy some CHINA printer and test on it. I thought it belong to printer. Some device has small memory, that can not handle big message.

Solution: I splitted my ticket message into more parts. With max-size 100 bytes/ packet. Can you support it on your method WriteBytes.

On react-native I am using under library. (https://github.com/innoveit/react-native-ble-manager)

xfiremen avatar Mar 19 '20 10:03 xfiremen

Actually I've tested on 3 cheap small Chinese Bluetooth printers and it looks like it works. I'm going to test bigger bytecode then.

andrey-ushakov avatar Mar 19 '20 14:03 andrey-ushakov

Yes, you are absolutely right about splitting the data. Normally we should use 20 bytes chunks (it's also the default value in the package you mentioned).

In the latest version, I'm splitting the data and using the sleep function before calling the platform-specific method.

This probably could be improved by splitting and waiting for the device response on the lower level (for Android and iOS) instead of using sleep.

PRs are welcomed!

andrey-ushakov avatar Mar 20 '20 00:03 andrey-ushakov

I update my project to using new version 0.25. When scan device, it fail. Error starting scan. Error: Unhandled Exception: MissingPluginException(No implementation found for method startScan on channel flutter_bluetooth_basic/methods) @andrey-ushakov

xfiremen avatar Mar 21 '20 09:03 xfiremen

@andrey-ushakov . I created pull request for you. Let check it! https://github.com/andrey-ushakov/flutter_bluetooth_basic/pull/6

xfiremen avatar Mar 22 '20 09:03 xfiremen

Error: Unhandled Exception: MissingPluginException(No implementation found for method startScan on channel flutter_bluetooth_basic/methods) Thank you! That's a bit strange why it's still working on iOS in my case (without changing pubspec .yaml).

Did you get a chance to check the printing issue btw? I've tested it on my cheap small Bluetooth printers and it works. However, the sleeping time (in ms) could be different for different printers. That's a "quick and dirty" solution and it must be improved in future releases.

andrey-ushakov avatar Mar 22 '20 10:03 andrey-ushakov

@andrey-ushakov . -queueSleepTimeMs must default 10ms & chunkSizeBytes 50. It worked well on most printers. I have tested on 7 models. Some issues when you rescan before connect. Some printers need more than 3-5 seconds to find. In writeData you rescan with 1 second timeout. One more thing. I think you don't need to disconnect after print.

xfiremen avatar Mar 24 '20 04:03 xfiremen

@andrey-ushakov . -queueSleepTimeMs must default 10ms & chunkSizeBytes 50. It worked well on most printers. I have tested on 7 models. Some issues when you rescan before connect. Some printers need more than 3-5 seconds to find. In writeData you rescan with 1 second timeout. One more thing. I think you don't need to disconnect after print.

I have made all adjustment in queueSleepTimeMs & chunkSizeBytes for printing jpg, but still I getting the image as breaking parts in printout. Printer model: Model MHT-P5801 How I can resolve this issue?, Please help.

hamzamon avatar Nov 24 '20 10:11 hamzamon

@hamzamon try increasing the chunkSizeBytes if its too slow, I had to set chunkSizeBytes to 200 and queueSleepTimeMs to 10 for smoother printing of images.

aakashbapna avatar Dec 04 '20 14:12 aakashbapna

I try with Niimbot B3S doesn't work anymore

Unlaytsabxwb avatar Oct 01 '21 16:10 Unlaytsabxwb

facing version mismatching when I use esc_pos_printer&esc_pos_bluetooth at the same time.. any solution for it?

Rabeeh96 avatar Nov 30 '21 04:11 Rabeeh96

Performance while printing text, QRcode, and others were good but the image was poor. Have you any solutions?

Pun-Mengly avatar Dec 31 '21 04:12 Pun-Mengly

How can we print pdf files without conversion to images?

Pun-Mengly avatar Dec 31 '21 10:12 Pun-Mengly

Actually I've tested on 3 cheap small Chinese Bluetooth printers and it looks like it works. I'm going to test bigger bytecode then.

Hi, Can your share the link of printers? Thanks! I tried it on Xprinter XP-T202UA via bluetooth. It actually works well on connecting the machine but not work for printing.

cmh81325 avatar Mar 20 '22 07:03 cmh81325