New Extension: ESC/POS Simple Converter for Bluetooth Printers

3,287 views
Skip to first unread message

Daniel K.

unread,
Jan 28, 2018, 3:55:36 PM1/28/18
to mitappinv...@googlegroups.com
I want to introduce a new extension that simplifies the communication with Bluetooth thermal printers and makes possible to create pretty cool apps. The ESC/POS Simple Converter enables to print formatted text, images, bar codes and QR codes without needing to have knowledge in ESC/POS programming. For example, you can print images from the assets, the SD card or the web. Just provide the name or the URL of the image. You can also take a photo with your camera and directly send it to your printer. A dithering algorithm is applied to create the illusion of a grayscale instead of monochrome black.

How to use this extension? The extension provides blocks for basic ESC/POS commands which will help inventors with their apps. After you have enabled Bluetooth and paired the devices, you can set up a connection. To send your data to the printer, just combine one block from the extension with a SendBytes block from the Bluetooth component. The ESC/POS Simple Converter returns the byte sequence your ESC/POS printer expects.

At the moment I have implemented the following blocks. You can find some examples how to use them in the attachment. The blocks for printing images, text and QR codes can be utilized with various options but also with reasonable default values. Take into account that some manufacturers might use different commands. If you have a manual, we can find a solution.

  • AlignCenter
  • AlignLeft
  • AlignRight
  • BlackWhiteReverseTextMode(boolean reverseMode)
  • ConvertImage(String image)
  • ConvertImageWithOptions(String image, int dotsPerLine, int threshold, boolean useDithering)
  • ConvertText(String text)
  • ConvertTextWithEncoding(String text, String encoding)
  • ConvertToBarCode(String text, int system)
  • ConvertToQRCode(String text)
  • ConvertToQRCodeWithOptions(String text, String errorCorrection, int sizeFactor)
  • CutPaper(boolean partialCut)
  • FormatTextMode(boolean otherFont, boolean bold, boolean doubleHeight, boolean doubleWidth, boolean unterline)
  • InitializePrinter
  • LineFeed
  • SelectCharacterCodePage(int Codepage)

After there had been several questions concerning bluetooth printers in this forum, I decided to develop this extension in order to simplify things for you.

Kind regards,
Daniel

Forum policy prohibits advertisements Daniel  Posting guidelines are here  https://groups.google.com/forum/#!category-topic/mitappinventortest/VSXuh8EBSMY  
You might want to establish your own web page for commercial activities.  Your  promotion text was removed.
ConnectBluetooth.PNG
ImageAndTextBlocks.PNG
QRCodeBlocks.PNG
Paper2.jpg
CameraBlocks.PNG
CameraBirds2.jpg

Taifun

unread,
Jan 28, 2018, 5:12:00 PM1/28/18
to MIT App Inventor Forum
Thank you very much for your contribution!
Unfortunately one of the moderators removed parts of your text because of forum guidelines...

I therefore would like to invite you to post again in the App Inventor For All forum (which does not have these restrictions).
You also might want to consider posting in the Thunkable, Appybuilder and Makeroid communities...
Keep up the good work!

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

Abraham Getzler

unread,
Jan 29, 2018, 9:57:10 AM1/29/18
to MIT App Inventor Forum
(added to the Printing section of FAQ)
(wink, wink, nudge, nudge)
ABG

Daniel K.

unread,
Feb 2, 2018, 7:16:39 AM2/2/18
to MIT App Inventor Forum
Sorry for the inconvenience and thanks for adding it to the FAQ section, Abraham!
Thank you for your advice, Taifun!

I have now set up a dedicated web page to host my extensions:
https://appinventordaniel.jimdo.com/

At the moment, you can find the following extensions over there:

ESC/POS Simple Converter
The ESC/POS Simple Converter enables to send formatted text, images, bar codes and QR codes from App Inventor to a bluetooth thermal printer without the need of having knowledge in ESC/POS programming.
https://appinventordaniel.jimdo.com/esc-pos-simple-converter/

Quick Sort
The Quick Sort extension provides a fast sorting algorithm for vast lists of numbers or text.
https://appinventordaniel.jimdo.com/quick-sort/

Object Manager
The Object Manager offers a convenient way of structuring and handling data as objects with attributes.
https://appinventordaniel.jimdo.com/object-manager/

Regards,
Daniel

Abraham Getzler

unread,
Feb 2, 2018, 10:01:17 AM2/2/18
to MIT App Inventor Forum
(added to Lists section of FAQ Part 1)

The Object Manager would benefit from a JSON import/export facility.

ABG

Reply all
Reply to author
Forward
0 new messages