B4J Library jSD_EscPosPrinter

This library allows you to print text and image to a bluetooth thermal printers
Works with Bluetooth and USB. For USB thermal printers you need the driver
Dependence: jBluetooth

This version requires an activation code. If you do not have a code then it will work in DEMO mode and you will only be able to print every 4 minutes.


jSD_EscPosPrinter

Author:
Star-Dust
Version: 1.30
  • BT_Printer
    • Events:
      • BluetoothIsDisabled
      • ConnectedToPrint (Success As Boolean)
      • DataReceived (Buffer() As Byte)
      • DiscoveryComplete (Printers As Map)
      • DiscoveryFinished
      • DiscoveryNewPrinter (Name As String, MacAdress As String)
      • DiscoveryNoDeviceFound
      • ErrorDiscovery
      • SendingError (Mac As String)
    • Functions:
      • AddBuffer_ArrayByte (B As Byte()) As String
      • AddBuffer_BarCode (Code As String) As String
      • AddBuffer_Bitmap (Bmp As Image, ShiftLeft As Int) As String
      • AddBuffer_List_Write (list As List) As String
      • AddBuffer_List_WriteLine (list As List) As String
      • AddBuffer_Tab (ArrayTab As Int()) As String
      • AddBuffer_Write (Text As String) As String
      • AddBuffer_WriteLine (Text As String) As String
      • CenterJustify As String
        after this command calls SendBufferToPrinter
      • Class_Globals As String
      • ClearBuffer As String
      • Close As String
      • Connected As Boolean
      • flushAllAndClose As String
      • Initialize (CallBack As Object, EventName As String, EncodingType As String, CodeActivation 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.
      • LeftJustify As String
        after this command calls SendBufferToPrinter
      • RightJustify As String
        after this command calls SendBufferToPrinter
      • SearchNewPrinter As String
      • SelectFromMac (Mac As String) As String
      • SendBufferToPrinter
    • Properties:
      • Spacing
        after setSpacing command calls SendBufferToPrinter
  • ESC_POS
    • Fields:
      • BoldOff As String
      • BoldOn As String
      • CutPaper As String
      • DoubleOff As String
      • DoubleOn As String
      • FontA_Bold As String
      • FontA_DoubleHight As String
      • FontA_DoubleWide As String
      • FontA_DoubleWideHeight As String
      • FontA_Normal As String
      • FontB_Bold As String
      • FontB_DoubleHeight As String
      • FontB_DoubleWide As String
      • FontB_DoubleWideHeight As String
      • FontB_Normal As String
      • Horizzontal As String
      • InitializePrinter As String
      • ItalicFontOff As String
      • ItalicFontOn As String
      • NoUnderline As String
      • QueryErrorCauses As String
      • QueryOfflineCauses As String
      • QueryPaperStatus As String
      • QueryPrinterStatus As String
      • Underline1 As String
      • Underline2 As String
      • Vertical As String
    • Functions:
      • Process_Globals As String
  • Encoding
    • Fields:
      • Chinese As String
      • ChineseS As String
      • Code_PC437 As Int
      • Code_PC850 As Int
      • Code_PC857 As Int
      • Code_PC858 As Int
      • Code_PC860 As Int
      • Code_PC863 As Int
      • Code_WPC1252 As Int
      • DOS_Latin_1 As String
      • IBM_PC As String
      • ISO8859 As String
      • UTF8 As String
      • Windows1252 As String
    • Functions:
      • Process_Globals As String
  • LAN_Printer
    • Events:
      • Connected (Success As Boolean)
      • DataReceived (Data() As Byte)
      • Diconnected
      • ErrorTrasmission
    • Fields:
      • Charset As String
    • Functions:
      • AddTab (ArrayTab As Int()) As String
        Add Tab
        eg. PrinterBLE.AddTab(Array As Byte(100,150,121))
      • Beep (Times As Byte, SecondsDurate As Byte) As String
        .Printer.Beep(1..9,1..9)
      • CenterJustify As String
        after this command calls SendBufferToPrinter
      • Class_Globals As String
      • Connect (Addr As String, Port As Int) As String
      • Disconnect As String
      • Initialize (CallBack As Object, EventName As String, CodeActivation As String) As String
        Initializes the object. You can add parameters to this method if needed.
        Initilize("192.168.1.100",9100,"YourCode")
      • InitializePrinter As String
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • LanConnection_Connected (Successful As Boolean) As String
      • LeftJustify As String
        after this command calls SendBufferToPrinter
      • PrintBitmap (bmp As Image) As String
      • RightJustify As String
        after this command calls SendBufferToPrinter
      • SetCodePage (Code As Byte) As String
        es. Printer.SetCodePage(06) for umlauts char
      • Write (Text As String) As String
        Write (Print) a Text
      • Write_ArrayByte (D As Byte()) As String
        Write (Send to Printer) a Array of Byte
        eg. PrinterBLE.Write_ArrayByte(Array As Byte(0x1D,150,23))
        eg. PrinterBLE.Write_ArrayByte("Text".GetBytes("UTF8"))
      • WriteBarCode (Code As String) As String
      • WriteBarCode2D (Code As String) As String
      • WriteLine (Text As String) As String
        Write (Print) a Text + CHLF
      • WriteList (list As List) As String
        Write (Print) a List
    • Properties:
      • CodeTable
        es. printer.setCodeTable(Enoding.Code_WPC1252)
        aftet this command calls SendBufferToPrinter
      • Spacing
        after setSpacing command calls SendBufferToPrinter
  • USB_Printer
    • Fields:
      • Constant As Int
    • Functions:
      • AddTab (ArrayTab As Int()) As String
        Add Tab
        eg. PrinterBLE.AddTab(Array As Byte(100,150,121))
      • Beep (Times As Byte, SecondsDurate As Byte) As String
        .Printer.Beep(1..9,1..9)
      • CenterJustify As String
        after this command calls SendBufferToPrinter
      • Class_Globals As String
      • Initialize (printerName As String, CodeActivation As String) As String
        Initilize("Printer","YourCode")
      • InitializePrinter As String
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • LeftJustify As String
        after this command calls SendBufferToPrinter
      • PrintBitmap (bmp As Image) As String
      • RightJustify As String
        after this command calls SendBufferToPrinter
      • SetCodePage (Code As Byte) As String
        es. Printer.SetCodePage(06) for umlauts char
      • Write (Text As String) As String
        Write (Print) a Text
      • Write_ArrayByte (D As Byte()) As String
        Write (Send to Printer) a Array of Byte
        eg. PrinterBLE.Write_ArrayByte(Array As Byte(0x1D,150,23))
        eg. PrinterBLE.Write_ArrayByte("Text".GetBytes("UTF8"))
      • WriteBarCode (Code As String) As String
      • WriteBarCode2D (Code As String) As String
      • WriteLine (Text As String) As String
        Write (Print) a Text + CHLF
      • WriteList (list As List) As String
        Write (Print) a List
    • Properties:
      • CodeTable
        es. printer.setCodeTable(Enoding.Code_WPC1252)
        aftet this command calls SendBufferToPrinter
      • Spacing
        after setSpacing command calls SendBufferToPrinter

_______________________________________________________________________________________________
1.30 Add lan/wifi connection
 

Attachments

  • jSD_EscPosPrinter.zip
    24.4 KB · Views: 82
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Here you will find examples for the Bluetooth and USB version


1724273173312.png
1724273259019.png
 

Attachments

  • SampleUSBPrinter.zip
    2.9 KB · Views: 103
  • SampleBTPrinter.zip
    3.1 KB · Views: 101
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Version 1.30 released
  • Added lan / wifi connection (To be used only for ESC/POS printers)

B4X:
Dim LanP As LAN_Printer
   
    LanP.Initialize(Me,"LanP","")
    LanP.Connect("192.168.1.101",5000)
   
    Wait For LanP_Connected(Success As Boolean)
    If Success Then
        LanP.Write("Hallo")
        LanP.Disconnect
End If
 
Last edited:
Top