B4A Library SD: BT Printer (Bluetooth)

Discussion in 'Additional libraries, classes and official updates' started by Star-Dust, Nov 4, 2017.

  1. Star-Dust

    Star-Dust Expert Licensed User

    With the new versions of B4A and the recent bluetooth library, the flush command was no longer needed. When sending data, it flushes and closes the connection
     
    microbox and vecino like this.
  2. vecino

    vecino Well-Known Member Licensed User

    Thank you very much for your help.
     
  3. vecino

    vecino Well-Known Member Licensed User

    Code:
    AddBuffer_Write (Text As StringAs String
    AddBuffer_WriteLine (Text 
    As StringAs String
    Hi again, what's the difference between AddBuffer_Write and AddBuffer_WriteLine?
    Thank you.
     
  4. Star-Dust

    Star-Dust Expert Licensed User

    In Basic WriteLn or WriteLine it has always added the CRLF carriage return at the end of the send. :)
     
    DonManfred and vecino like this.
  5. vecino

    vecino Well-Known Member Licensed User

    Great.
    Thank you.
     
  6. Star-Dust

    Star-Dust Expert Licensed User


    AddBuffer_Bitmap (Path As String, Filename As String, LeftSpace As Int) As String

    In the AddBuffer method you find a LeftSpace field, used to move the image starting from the left margin.

    If you have problems with some printers, this may be because not all printers use the same method / command for images, in fact you also find the AddBuffer_Bitmap2 command. Make sure the image is not too large or the distance is not such that it loses the connection from the printer.

    the sdk should not be sent to ArrayByte. the SDK is already a library, you should eventually connect it to your B4X code and recall the methods if you have the sdk documentation.
    ArrayByte is used to send raw data (images, text or other) to the printer without the filter of my library, so as to add missing methods, or specific methods for certain printer models
     
    Erel likes this.
  7. zenlab

    zenlab Member Licensed User

    mmmm. with your library version 0.04 (sd_bt_printer_7 and sd_bt_printer_ba7) if I add a parameter after the Path and the filename, return error for too many parameters
     
  8. Star-Dust

    Star-Dust Expert Licensed User

    A solution would be, go to the first post of this thread and download the latest version
     
  9. zenlab

    zenlab Member Licensed User

    I've download the first post library and b4a give me always the same problem....and always the same version: 0.0.4
    (in IT: ho scaricato la versione del primo post fin dall'inizio ma non c'è la versione 0.05....prova anche tu a verificare.... questo è un pezzo dell'xml: <version>0.04</version>)
     
  10. Star-Dust

    Star-Dust Expert Licensed User

    Update to 0.05
     
  11. zenlab

    zenlab Member Licensed User

    OK, now is ok the version but I have the same problem....the image always start from 1cm to the left....in all of this function:
    Code:
    Stampa.AddBuffer_Bitmap(File.DirAssets,"printtest.bmp",10)
    Stampa.AddBuffer_Bitmap(
    File.DirAssets,"printtest.bmp",0)
    and if I use this:
    Code:
    Stampa.AddBuffer_Bitmap(File.DirAssets,"printtest.bmp",1)
    the printer make only lot of charaters but not image
     
  12. Star-Dust

    Star-Dust Expert Licensed User

    Usually I do not, but exceptionally I have added a new method AddBuffer_Bmp()
    Use a different system to move the image to the left. I hope it works, otherwise I can not help you further.

    If you get ASCII characters instead of the image probably your printer is not compatible with this method, maybe you could have better results with AddBuffer_Bitmap2. If this is not the case, you will need to see the printer's instruction manual and enter the codes with AddBuffer_ArrayByte.

    In addition, the bitmap if it is too large generates errors with the printer. Try reducing with
    Code:
    Stampa.AddBuffer_bmp(LoadBitmap(pathfile).Resize (width, Heigth, True),0)
     
    Last edited: Jul 5, 2018
  13. zenlab

    zenlab Member Licensed User

    MITICOOOOOOO!!!!!!
    many many thanks!!!
    THIS WORKS GREAT
     
  14. zenlab

    zenlab Member Licensed User

    One last thing ... it would be possible to add the flushall function without the close ....
     
  15. Star-Dust

    Star-Dust Expert Licensed User

    Sorry it's not possible. To send data in bluetooth my library uses the ASyncStream class of the RandomAcessFile library (rel 2.32).
    The submission procedure ends with the Send and Close command
    See the documentation here
     
  16. zenlab

    zenlab Member Licensed User

    OK, but there is a function that permit to remain connected after print? Now whenever I send a print, the printer need to reconnect for send another print...in the version 0.04 sd_bt_printer_ba7 the printer remain connected after a print until I call close...
     
  17. Star-Dust

    Star-Dust Expert Licensed User

    No. The old version used a previous version of RandomAcessFile that allowed flushing without closing.
    With B4A 7+ the library has been updated and the flush command is mesos together with close, as you will have read in the tutorial I have indicated to you.

    At the end of printing, try to reconnect to the printer using the ID code of the printer. Better if after a 10/20 second pause.

    In the future I will implement SendBuffer, to send the buffer to the printer. But I do not know if it will solve the question because it is sent into the system buffer. The flush empties intermanete system buffers.
     
    Last edited: Jul 5, 2018
  18. Star-Dust

    Star-Dust Expert Licensed User

    Update rel. 0.07

    Add this method
    • AddBuffer_Bmp (bmp As Bitmap, ShiftLeft As Int) As String
    • SendBufferToPrinter
    If you want to make a donation click on the DONATE button at the bottom of this Post
     
    Last edited: Jul 6, 2018
    vecino likes this.
  19. Star-Dust

    Star-Dust Expert Licensed User

    Update to release 0.08
    • Change methods of inserting images
    • Fixed Bugs on the image shift system on the left
    • Improved sending to print (SendBufferToPrint)
    The next update will provide for the library to preview a print by generating an image or a view
     
    Last edited: Aug 24, 2018
    vecino likes this.
  20. Star-Dust

    Star-Dust Expert Licensed User

    Preview announcement.

    The new 0.09 version will be released in days.
    I have eliminated some non-working printing methods and added a graphic preview of the print.

    Here's what the new version will allow
    Video1.gif upload_2018-9-2_17-23-30.png

    In the meantime you can try the DEMO version that you find in post#1

    PS. To print the QR CODES with your BT thermal printer you can create an image containing the QR code with the help of the @Erel library that you can find here
    Or can use this library of @Johan Schoeman
     
    Last edited: Sep 2, 2018
    MarcoRome, Erel and moster67 like this.
Loading...
  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