Android Code Snippet Print to a Bluetooth POS-receipt printer with matching codepage

Discussion in 'Code Snippets' started by KMatle, Mar 2, 2017.

  1. KMatle

    KMatle Expert Licensed User

    Original thread:

    I simlified the above's example to print on a BT POS printer like this


    with the correct codepage to print special chars like "äöüßéè", etc. (codepage 1252).


    - switch on the printer
    - switch on BT on your device
    - pair your device with the printer (pw on my printer is 1234, take a look at the manual)
    - wait 'till it's paired and see the printer's name
    - insert the first unique chars in the code (the MAC address is retrieved via the printers name)
    - run the app and print

    #Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: Bluetooth POS Printing
    #VersionCode: 1
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
    #End Region

    Sub Process_Globals
    Dim PrintBuffer As String

    Dim BtAdmin As BluetoothAdmin
    Dim BTConnection As Serial
    Dim Printer As TextWriter
    End Sub

    Sub Globals
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
    Dim PairedDevices As Map
            PairedDevices = BTConnection.GetPairedDevices
    Dim l As List
    Dim DeviceName, MacAddress As String
    For i = 0 To PairedDevices.Size - 1 'Check all devices
    Log(DeviceName & " -> " & MacAddress)
    If DeviceName.Contains("Thermal"Then 'Insert the BT-Name of the printer or use the MAC address
    End If
    End If
    End Sub

    Sub Activity_Resume
    End Sub

    Sub Activity_Pause
    End Sub

    Sub Printer_Connected (Success As Boolean)
    If Success Then
    "windows-1252"'important to print f.e. German/French chars
            PrintBuffer=Chr(27)&"t"&Chr(16)&"Hello öäüßéèê" 'Set codepage 1252 

    'disable this if you like
    Msgbox("No printer found...","Print error")
    End If
    End Sub
    Beja, rraswisak, ZenWhisk and 11 others like this.
  2. hasexxl1988

    hasexxl1988 Active Member Licensed User

    Nice is helpful, and have your a a solution for Image printing? :D
  3. Widget

    Widget Well-Known Member Licensed User

  4. KMatle

    KMatle Expert Licensed User

    See here: but I did not try so far.

    What you can do is search Google for a VB(.net) example and port the code. I think there are tons evailable. Maybe I do a convert.

    I added "receipt" to the title :) And yes, the printer (about 50€) has a good quality and it pairs very fast and reliable.
    f0raster0 likes this.
  5. Tom Christman

    Tom Christman Active Member Licensed User

    I believe POS is "Point of Sale".
    Beja likes this.
  6. Widget

    Widget Well-Known Member Licensed User

    Correct. But when I first read it I read it too quickly and thought it stood for "Piece of S...t Printer". LOL
    KMatle likes this.
  7. KMatle

    KMatle Expert Licensed User

  8. HAH

    HAH Active Member Licensed User

    Great for English ..

    Arabic windows-1256 not working!
    Also how to print right to left direction?
    I want using your printing approach not another library.
    abolfazlmarj likes this.
  9. scsjc

    scsjc Active Member Licensed User

    i try to convert a code vb to print image... but can't have a solution... my sample code is and only cant a print pixels on a bucle 0-255, i don't know if that can you help to find a print image ...
  10. Eugene Puah

    Eugene Puah New Member Licensed User

    Matle, thanks a lot for your POS Printing example which has been a great help for me in picking up BT printing.

    Eugene Puah(Malaysia)
    KMatle likes this.
  11. DonManfred

    DonManfred Expert Licensed User

    Please do answer with the default font. It is not needed to change the font. You can use bold for single words to mark them. But writing everything bold and italic only make the post more difficult to read...
    KMatle likes this.
  12. Eugene Puah

    Eugene Puah New Member Licensed User

    Sorry about the bold fonts. I will pay attention to this next time.
    Eugene Puah
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice