This extension allows you to print text, images, bar and qr codes, etc in a Thermal Printer.
Explanation of blocks
This block returns a command for printing a text
charset – a string for the character encoding for example “UTF-8”
text – a string which value will be the printed text
changeFont – a Boolean value (true or false) for changing the printer font
size – a number (0-3) to define the text size
bold – a Boolean value (true or false) to define bold font
underline – a Boolean value (true or false). If true is used, a line under the text will be printed
feedline – a Boolean value (true or false) if a true value is used, the printer will feed a line after the text is printed. This will be for most cases. Use false only if you are going to use the Tab Function.
Returns the command for setting the alignment of the printer.
alignment – expects a number to set the alignment
0 for Left , 1 for Center, 2 for Right
Or you can just simply use these blocks:
This block will set extra options to text.
invert – a Boolean value. True, will print the text in a black background so the text can be white. False is normal
rotate – a Boolean value. True will rotate the text 90 degrees. False is normal
upsideDown – a Boolean value. True will set the text Upside Down. False is normal
This block returns the command for setting the code page for your printer.
codePage – excepts a number for the Code Page to be set depending on your printer:
You can know this number in your printer manual, or printing the test page. See this example from my printer:
This block returns the command to cut the printer’s paper
fullCut – a Boolean value. If true the printer will fully cut the paper, if false it will be only a partial cut.
Note: Not every printer has this function.
This block will return the command for printing an image.
image – a string including the path of the image to be printed. The image can be from assets, storage and from an URL.
width – a number for setting the width of the image, some printers have a maximum value so if it this value is exceeded the printer may not print the image but a lot of characters. So please test this number first after using it your final app. Note: 150-200 may work in most printers
dithering – a Boolean value to define if the image will be printed using dithering or not.
This block will return the command for opening the cash drawer connected to your printer via a RJ connector. (Note: I have not tested this command because I don’t have a Cash Drawer)
pulse – a number for sending the pulse to the cash drawer
0 will send a pulse to pin 2
1 will send a pulse to pin 5
This block will return the command for printing a QR Code.
text – a String to indicate the text that will be printed as a QR.
correction – a number (0-3) to indicate the correction level for the QR.
size – a number (1-16) to manipulate the size of the QR Code.
This block will return the command for printing a BarCode
text – a string which value is the text to be converted as barcode.
System – a number for setting the barcode system. (you can check your printer’s manual to see the supported systems)
visibleText – a Boolean value. If true the text will be printer above the barcode. If false the text won’t be printed, only the barcode
height – a number (1-255)
width – a number (2-6)
This block will return the command to print a Pdf417 barcode
text - a string containing the text to be converted and printed as a PDF417 barcode.
This block will set the positions when a tabulation is made
A List with the positions of the tabs. Example:
This block will return the command for doing a tabulation for the defined positions. You will normally use this after printing a Text with the feedLine parameter set to False.
This block will return the command to feed the printer’s paper.
lines – a number of the amount of lines to be feed.
Now the most important.
This extension only creates the commands for printing but it doesn’t make any connection to the printer. So, how do you communicate with it?
Well for bluetooth printing you can just simply use the Bluetooth Client component. Like this example:
And for Network printing (A printer connected via Wi-Fi or LAN cable to your local network)
I created another extension, Called SimpleSocket, specifically for this purpose.
It only includes two Blocks.
Creates the connection to the printer via its IP Address.
ipAddress - a string containing the ip address of your printer
connectionPort - a number for setting the port for the connection if needed (otherwise 9100 should work)
secret - a string containing the password for the connection if needed (otherwise any random string should work)
timeOut - a number to define the timeout for the connection (in ms).
list - the list with the commands for printing using the Thermal Printing extension.
An event raised when an error is found. It will return the error message as an String.
NOTE: This extension was tested on the following printers:
• Epson TM-m10 (bluetooth)
• LOSRECAL Mini Bluetooth Printer
• 3nstar RPT0010 (bluetooth)
• 3nstar RPT006B (connected to the network via LAN cable)
What’s included with the extension?
• ThermalPrinter aix
• SimpleSocket aix
• An aia for simple understanding of the extension
$7 USD / PayPal
Send me a PM if you are interested in buying the extension.
To App Inventor for this amazing platform
To Shreyash for creating Rush