B4J Library [B4X] SD Zebra (printer)

This library is the result of my first approach with Zebra printers. I started by connecting via LAN (or Wi-Fi) ZPL language.
I plan to connect via BLE and perhaps also via USB. Have a good time. Preview only works if you have an internet connection
For ESC/POS Printer see here
The Demo version does not print images, barcodes, raw commands

NB
: This is a demo version, each print will show the SD symbol. Contact me privately for a full version.
Some Honeywell printers support the ZPL II language to make them compatible with Zebra and facilitate replacement. So this library might work on Honeywell as well



Anyone who wants a different version from those distributed (such as Bluetooth SPP, USB, RS) can contact me privately.
OS
Bluetooth SPP
BLE (Beacon)
USB
LAN / WIFI
RS 232
NFC
Android​
x (On request)​
x​
x (on request)​
x​
iOs​
x​
x​
Window​
x (On request)​
x​
x​



aSD_Zebra

Author:
Star-Dust
Version: 1.11
  • BLEZebraPrinter
    • Events:
      • BLEisOFF
      • Connected (services As List)
      • Disconnected
      • ImageWriteComplete
      • PrinterFound (Name As String, ID As String)
      • StateChanged (msg As String)
      • WriteComplete (Characteristic As String, Success As Boolean)
    • Fields:
      • CharatteristicName As String
      • currentState As Int
      • Encoding As String
      • Rotate180 As String
      • Rotate270 As String
      • Rotate90 As String
      • RotateNormal As String
      • ServiceName As String
    • Functions:
      • Active (CodeActivation As String) As String
      • AddBarCode (X As Int, Y As Int, Height As Int, Code As String, Size As Int) As String
        CODE 128
        Zebra.AddBarCode(50,50,"1234567890",5)
      • AddBarCodeEAN13 (X As Int, Y As Int, Height As Int, Code As String, Size As Int) As String
        EAN13
        Zebra.AddBarCodeEAN13(50,50,"1234567890",5)
      • AddCircle (X As Int, Y As Int, radius As Int, StrokeWidth As Int, Filled As Boolean) As String
        Zebra.AddCircle(50,50,25,3,false)
      • AddHorizLine (X As Int, Y As Int, Width As Int, StrokeWidth As Int) As String
        Zebra.AddHorizLine(50,50,700,3)
      • AddImage (X As Int, Y As Int, bmp As B4XBitmap) As String
        Zebra.AddImage() ' not active
      • AddLogoSD (X As Int, Y As Int)
        Add logo SD to coordinate
      • AddQRcode (X As Int, Y As Int, Height As Int, Code As String, Size As Int) As String
        Zebra.AddQRcode(50,50,"1234567890",5)
      • AddRaw (Text As String) As String
      • AddRectangle (X As Int, Y As Int, Width As Int, Height As Int, StrokeWidth As Int, Filled As Boolean, InvertBrush As Boolean) As String
        Zebra.AddRectangle(50,50,100,100,3,false,false)
      • AddRectangleRounded (X As Int, Y As Int, Width As Int, Height As Int, StrokeWidth As Int, Filled As Boolean, Rounded As Int) As String
        Zebra.AddRectangleRounded(50,50,100,100,3,false,5)
      • AddText (X As Int, Y As Int, Text As String, TextSize As Int, Bold As Boolean) As String
        Zebra.AddText(50,50,"Text",50, false)
      • AddTextRotate (X As Int, Y As Int, Text As String, TextSize As Int, Bold As Boolean, Rotation As String) As String
        Zebra.AddTextRotate(50,50,"Text",50, false,Zebra.RotateNormal)
        Zebra.AddTextRotate(50,50,"Text",50, false,Zebra.Rotate90)
      • AddVertLine (X As Int, Y As Int, Height As Int, StrokeWidth As Int) As String
        Zebra.AddVertLine(400,100,300,3)
      • Class_Globals As String
      • Connect (ID As String) As String
        CharatteristicName = "2AF0" or "2AF1"
      • Disconnect As String
      • Initialize (CallBack As Object, EventName As String) As String
        Initializes the object. You can add parameters to this method if needed.
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • Preview As String
        Evito di usare okHttpUtils
      • Print As String
      • ScanPrinter As String
      • StopScanning As String
    • Properties:
      • isConnect As Boolean [read only]
      • isScanning As Boolean [read only]
      • LabelWidth
      • Raw As String [read only]
      • BlackRange
  • LanZebraPrinter
    • Events:
      • Opened (Success As Boolean)
      • Preview (Success As Boolean, bmp As B4XBitmap)
    • Fields:
      • desktop As Int
      • Encoding As String
      • Mobile As Int
      • Rotate180 As String
      • Rotate270 As String
      • Rotate90 As String
      • RotateNormal As String
    • Functions:
      • Active (CodeActivation As String) As String
      • AddBarCode (X As Int, Y As Int, Height As Int, Code As String, Size As Int) As String
        Code 128
        Zebra.AddBarCode(50,50,"1234567890",5)
      • AddBarCodeEAN13 (X As Int, Y As Int, Height As Int, Code As String, Size As Int) As String
        EAN13
        Zebra.AddBarCodeEAN13(50,50,"1234567890",5)
      • AddBarCodeEAN8 (X As Int, Y As Int, Height As Int, Code As String, Size As Int) As String
        EAN8
        Zebra.AddBarCodeEAN8(50,50,"1234567890",5)
      • AddCircle (X As Int, Y As Int, radius As Int, StrokeWidth As Int, Filled As Boolean) As String
        Zebra.AddCircle(50,50,25,3,false)
      • AddHorizLine (X As Int, Y As Int, Width As Int, StrokeWidth As Int) As String
        Zebra.AddHorizLine(50,50,700,3)
      • AddImage (X As Int, Y As Int, bmp As B4XBitmap) As String
        Zebra.AddImage() ' not active
      • AddLogoSD (X As Int, Y As Int)
        Add logo SD to coordinate
      • AddQRcode (X As Int, Y As Int, Height As Int, Code As String, Size As Int) As String
        Zebra.AddQRcode(50,50,"1234567890",5)
      • AddRaw (Text As String) As String
      • AddRectangle (X As Int, Y As Int, Width As Int, Height As Int, StrokeWidth As Int, Filled As Boolean, InvertBrush As Boolean) As String
        Zebra.AddRectangle(50,50,100,100,3,false,false)
      • AddRectangleRounded (X As Int, Y As Int, Width As Int, Height As Int, StrokeWidth As Int, Filled As Boolean, Rounded As Int) As String
        Zebra.AddRectangleRounded(50,50,100,100,3,false,5)
      • AddText (X As Int, Y As Int, Text As String, TextSize As Int, Bold As Boolean) As String
        Zebra.AddText(50,50,"Text",50, false)
      • AddTextRotate (X As Int, Y As Int, Text As String, TextSize As Int, Bold As Boolean, Rotation As String) As String
        Zebra.AddTextRotate(50,50,"Text",50, false,Zebra.RotateNormal)
        Zebra.AddTextRotate(50,50,"Text",50, false,Zebra.Rotate90)
      • AddVertLine (X As Int, Y As Int, Height As Int, StrokeWidth As Int) As String
        Zebra.AddVertLine(400,100,300,3)
      • Class_Globals As String
      • Clear As String
      • Close As String
      • Initialize (Callback As Object, Event As String) As String
        Initializes the object. You can add parameters to this method if needed.
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • Open (Host As String, TypePrinter As Int) As String
        Zebra.Open("192.168.1.202",Zebra.desktop)
      • Preview As String
        Evito di usare okHttpUtils
      • Print As String
      • PrintAndClose
    • Properties:
      • LabelWidth
      • Raw As String [read only]
      • BlackRange
  • UsbZebraPrinter
    Ctrl + click to build b4xlib: ide://run?file=%JAVABIN%\jar.exe&WorkingDirectory=%PROJECT%\..&Args=-cMf&Args=%PROJECT_NAME%.b4xlib&&Args=..&Args=*.bas&Args=manifest.txt
    preview http://labelary.com/viewer.html
    • Events:
      • Opened (Success As Boolean)
      • Preview (Success As Boolean, bmp As B4XBitmap)
    • Fields:
      • desktop As Int
      • Encoding As String
      • Mobile As Int
      • Rotate180 As String
      • Rotate270 As String
      • Rotate90 As String
      • RotateNormal As String
    • Functions:
      • Active (CodeActivation As String) As String
      • AddBarCode (X As Int, Y As Int, Height As Int, Code As String, Size As Int) As String
        Code 128
        Zebra.AddBarCode(50,50,"1234567890",5)
      • AddBarCodeEAN13 (X As Int, Y As Int, Height As Int, Code As String, Size As Int) As String
        EAN13
        Zebra.AddBarCodeEAN13(50,50,"1234567890",5)
      • AddBarCodeEAN8 (X As Int, Y As Int, Height As Int, Code As String, Size As Int) As String
        EAN8
        Zebra.AddBarCodeEAN8(50,50,"1234567890",5)
      • AddCircle (X As Int, Y As Int, radius As Int, StrokeWidth As Int, Filled As Boolean) As String
        Zebra.AddCircle(50,50,25,3,false)
      • AddHorizLine (X As Int, Y As Int, Width As Int, StrokeWidth As Int) As String
        Zebra.AddHorizLine(50,50,700,3)
      • AddImage (X As Int, Y As Int, bmp As B4XBitmap) As String
        Zebra.AddImage() ' not active
      • AddLogoSD (X As Int, Y As Int)
        Add logo SD to coordinate
      • AddQRcode (X As Int, Y As Int, Height As Int, Code As String, Size As Int) As String
        Zebra.AddQRcode(50,50,"1234567890",5)
      • AddRaw (Text As String) As String
      • AddRectangle (X As Int, Y As Int, Width As Int, Height As Int, StrokeWidth As Int, Filled As Boolean, InvertBrush As Boolean) As String
        Zebra.AddRectangle(50,50,100,100,3,false,false)
      • AddRectangleRounded (X As Int, Y As Int, Width As Int, Height As Int, StrokeWidth As Int, Filled As Boolean, Rounded As Int) As String
        Zebra.AddRectangleRounded(50,50,100,100,3,false,5)
      • AddText (X As Int, Y As Int, Text As String, TextSize As Int, Bold As Boolean) As String
        Zebra.AddText(50,50,"Text",50, false)
      • AddTextRotate (X As Int, Y As Int, Text As String, TextSize As Int, Bold As Boolean, Rotation As String) As String
        Zebra.AddTextRotate(50,50,"Text",50, false,Zebra.RotateNormal)
        Zebra.AddTextRotate(50,50,"Text",50, false,Zebra.Rotate90)
      • AddVertLine (X As Int, Y As Int, Height As Int, StrokeWidth As Int) As String
        Zebra.AddVertLine(400,100,300,3)
      • Class_Globals As String
      • Clear As String
      • getRaw As String
      • Initialize (Callback As Object, Event As String) As String
        Initializes the object. You can add parameters to this method if needed.
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • Preview As String
        Evito di usare okHttpUtils
      • Print (printer As String) As String
      • PrintAndClose (printer As String) As String
      • setLabelWidth (Width As Int) As String
    • Properties:
      • LabelWidth
      • Raw As String [read only]
      • BlackRange



Update log
  • 1.01
    • Added printer type parameter on the Open method. It can be desktop or mobile printer
    • Added AddTextRotate command. Enter constants to pass as parameter (RotateNormal, Rotate90, Rotate180, Rotate270)
  • 1.02 Added method AddImage
  • 1.03 Fix bugs
  • 1.05 Added class for printing with BLE (BLE Not available for B4J)
  • 1.06 Fix bugs
  • 1.07 Added AddBarCodeEAN13 method
  • 1.08 Added AddBarCodeEAN8 method and Fix Bug
  • 1.09 Fix Bugs on authentication and streaming channel
  • 1.10 Added USB communication in B4J version, Fix bugs QR code
  • 1.11 Added AddLogoSD and BlackRange (Limit for the transformation between color and black and white images))
 

Attachments

  • jSD_Zebra 1.11.zip
    21.9 KB · Views: 265
  • aSD_Zebra 1.11.zip
    24.3 KB · Views: 298
  • iSD_Zebra 1.11.zip
    223.9 KB · Views: 258
Last edited:

jaelani

Member
After donating, this feature will be active

AddImage (X As Int, Y As Int, bmp As B4XBitmap) As String
Zebra.AddImage() ' not active
 

Attachments

  • addimage.jpg
    addimage.jpg
    404.8 KB · Views: 162

Javier Lovay

Member
Licensed User
Longtime User
Hello. I have been using this magnificent library for some time. But now I have the problem that it does not print correctly with my USB printer and it comes out as seen in the photo, I have another one the same but it is wifi and the label comes out perfectly fine. What can I do to solve it?
 

Attachments

  • WhatsApp Image 2023-12-22 at 13.14.57.jpeg
    WhatsApp Image 2023-12-22 at 13.14.57.jpeg
    168.7 KB · Views: 119

Star-Dust

Expert
Licensed User
Longtime User
Hello. I have been using this magnificent library for some time. But now I have the problem that it does not print correctly with my USB printer and it comes out as seen in the photo, I have another one the same but it is wifi and the label comes out perfectly fine. What can I do to solve it?
I see that it is printing commands but not executing them. Is it a Zebra or an ESC/POS?
Which Zebra model is it?
 

Javier Lovay

Member
Licensed User
Longtime User
I am working for BLE and USB. I already have the classes ready but I have to do the tests and I don't have a printer.

Trying ESC / POS printers the BLE and USB connection works, so I'm very confident it works on ZEBRA too
Is a GG-AT90W.
I have another one just like it, but with Wi-Fi connectivity, and it works perfectly.
I installed the Linux, Windows and Mac drivers and in all 3 OS it does the same.
 

Javier Lovay

Member
Licensed User
Longtime User

Javier Lovay

Member
Licensed User
Longtime User
I have found the solution to the problem. I set my printer to Generic Text-Only Printer and it works correctly. THANK YOU.
 
Top