Reputation: 351
I need to add printing functionality on a zebra zq520 bluetooth thermal printer. I manage to do so using the flutter_blue plugin but I am not happy with the implementation. I hate to break the string to smaller chunks in order to pass through bluetooth (and wait!!!!!). I was wondering if there is a better approach, like the one we used in the (good?) old days of java for android using the android.bluetooth.BluetoothAdapter class
Thanks.
Upvotes: 2
Views: 3241
Reputation: 351
I ended up creating my own plugin.
EDIT: 2021/11/29 integrate some comments from comments section
This code is not limited to zpl. In theory it can support every printer language that sends clear text to bluetooth serial
It is only for Android
For this source code to works as is:
printToBT("^XA ^FX Top section with logo, name and address. ^CF0,60 ^FO50,50^GB100,100,100^FS ^FO75,75^FR^GB100,100,100^FS ^FO93,93^GB40,40,40^FS ^FO220,50^FDIntershipping, Inc.^FS ^CF0,30 ^FO220,115^FD1000 Shipping Lane^FS ^FO220,155^FDShelbyville TN 38102^FS ^FO220,195^FDUnited States (USA)^FS ^FO50,250^GB700,3,3^FS ^FX Second section with recipient address and permit information. ^CFA,30 ^FO50,300^FDJohn Doe^FS ^FO50,340^FD100 Main Street^FS ^FO50,380^FDSpringfield TN 39021^FS ^FO50,420^FDUnited States (USA)^FS ^CFA,15 ^FO600,300^GB150,150,3^FS ^FO638,340^FDPermit^FS ^FO638,390^FD123456^FS ^FO50,500^GB700,3,3^FS ^FX Third section with bar code. ^BY5,2,270 ^FO100,550^BC^FD12345678^FS ^FX Fourth section (the two boxes on the bottom). ^FO50,900^GB700,250,3^FS ^FO400,900^GB3,250,3^FS ^CF0,40 ^FO100,960^FDCtr. X34B-1^FS ^FO100,1010^FDREF1 F00B47^FS ^FO100,1060^FDREF2 BL4H8^FS ^CF0,190 ^FO470,955^FDCA^FS ^XZ")
You will get this:
One more thing: keep in mind that if you want to print special language characters (I need to print Greek) you have to find the correct font that is installed in your printer. For example: In order to print Greek characters I have to integrate this
^CWN,E:TT0003M_.FNT
just after the first ^XA. Then I use the N font in order to print Greek. It is very flexible if you understand the basics
Hope it helps
Upvotes: 7