ThermalPrinterESCPOS
Thermal Printer ESC/POS Library For Android.
Install / Use
/learn @EmHaseeb/ThermalPrinterESCPOSREADME
ThermalPrinter ESC/POS Android library
Useful library to help Android developers to print with (Bluetooth, WIFI, Network, USB) thermal printers ESC/POS.
❤️ Supporting
⭐ Star this repository to support this library. You can contribute to increase the visibility of this library 🙂
❤️ Whats New in 
- CashTray/CashBox/CashDrawer Support Added.
- Encoding Improvemed.
- CashTray related function are mentioned below:
new Thread(new Runnable() {
public void run() {
try {
EscPosPrinter printer = new EscPosPrinter(new TcpConnection(ip, port), 203, 65f, 42);
printer.openCashBox();
printer.disconnectPrinter();
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
EscPosPrinter printer = null;
try {
printer = new EscPosPrinter(BluetoothPrintersConnections.selectFirstPaired(), 203, 48f, 32);
printer.printFormattedTextAndOpenCashBox(
"[C]<img>" + PrinterTextParserImg.bitmapToHexadecimalString(printer, getApplicationContext().getResources().getDrawableForDensity(R.drawable.testp, DisplayMetrics.DENSITY_MEDIUM)) + "</img>\n" +
"[L]\n" +
"[C]<u><font size='big'>ORDER N°1125</font></u>\n[L]\n" +
"[L] _________________________________________\n" +
"[L] Description [R]Amount\n[L]\n" +
"[L] <b>Beef Burger [R]10.00\n" +
"[L] Sprite-200ml [R]3.00\n" +
"[L] _________________________________________\n" +
"[L] TOTAL [R]13.00 BD\n" +
"[L] Total Vat Collected [R]1.00 BD\n" +
"[L]\n" +
"[L] _________________________________________\n" +
"[L]\n" +
"[C]<font size='tall'>Customer Info</font>\n" +
"[L] EM Haseeb\n" +
"[L] 14 Streets\n" +
"[L] Cantt, LHR\n" +
"[L] Tel : +923040017916\n" +
"[L]\n" +
"[L] <barcode type='ean13' height='10'>831254784551</barcode>\n[L]\n" +
"[L] <qrcode>http://github.com/EmHaseeb/</qrcode>\n[L]\n[L]\n[L]\n",5
);
printer.disconnectPrinter();
} catch (EscPosConnectionException | EscPosParserException | EscPosEncodingException | EscPosBarcodeException e) {
e.printStackTrace();
}
Table of contents
- Android version
- Tested printers
- Test It !
- Installation
- Bluetooth
- TCP
- USB
- Charset encoding
- Formatted text : syntax guide
- Class list
- Contributing
Android version
Minimum SDK Version 16 Android 4.1 and above are supported.
Tested printers
- EPSON TM-T88VI (121): SERIAL, USB, ETHERNET (Tested over Network/Ethernet 📶)
- EPSON TM-T20 SERIES (Tested over USB 🔌)
- Sewoo LK-P41 (Bluetooth Printer)
- OmniLink® TM-m50 POS Thermal Receipt Printer (Tested over Wifi)
Test it !
To test this library, it's very simple.
- Create a directory and open a terminal inside
- Run
git clone https://github.com/EmHaseeb/ThermalPrinterESCPOS.git . - Open the directory with Android Studio
- Test it
Installation
Step 1. Add the JitPack repository to your build file. Add it in your root /build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency in /app/build.gradle :
dependencies {
...
implementation 'com.github.EmHaseeb:ThermalPrinterESCPOS:1.0.2'
}
Bluetooth
Bluetooth permission
Be sure to have <uses-permission android:name="android.permission.BLUETOOTH" />, <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />, <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />, <uses-permission android:name="android.permission.BLUETOOTH_SCAN" /> in your AndroidManifest.xml.
Also, you have to check the bluetooth permission in your app like this :
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.S && ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH}, MainActivity.PERMISSION_BLUETOOTH);
} else if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.S && ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_ADMIN) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH_ADMIN}, MainActivity.PERMISSION_BLUETOOTH_ADMIN);
} else if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S && ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH_CONNECT}, MainActivity.PERMISSION_BLUETOOTH_CONNECT);
} else if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S && ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_SCAN) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH_SCAN}, MainActivity.PERMISSION_BLUETOOTH_SCAN);
} else {
// Your code HERE
}
Bluetooth code example
The code below is an example to write in your activity :
EscPosPrinter printer = null;
try {
printer = new EscPosPrinter(BluetoothPrintersConnections.selectFirstPaired(), 203, 48f, 32);
printer.printFormattedTextAndCut(
"[C]<img>" + PrinterTextParserImg.bitmapToHexadecimalString(printer, getApplicationContext().getResources().getDrawableForDensity(R.drawable.testp, DisplayMetrics.DENSITY_MEDIUM)) + "</img>\n" +
"[L]\n" +
"[C]<u><font size='big'>ORDER N°1125</font></u>\n[L]\n" +
"[L] _________________________________________\n" +
"[L] Description [R]Amount\n[L]\n" +
"[L] <b>Beef Burger [R]10.00\n" +
"[L] Sprite-200ml [R]3.00\n" +
"[L] _________________________________________\n" +
"[L] TOTAL [R]13.00 BD\n" +
"[L] Total Vat Collected [R]1.00 BD\n" +
"[L]\n" +
"[L] _________________________________________\n" +
"[L]\n" +
"[C]<font size='tall'>Customer Info</font>\n" +
"[L] EM Haseeb\n" +
"[L] 14 Streets\n" +
"[L] Cantt, LHR\n" +
"[L] Tel : +923040017916\n" +
"[L]\n" +
"[L] <barcode type='ean13' height='10'>831254784551</barcode>\n[L]\n" +
"[L] <qrcode>http://github.com/EmHaseeb/</qrcode>\n[L]\n[L]\n[L]\n"
);
printer.disconnectPrinter();
} catch (EscPosConnectionException e) {
e.printStackTrace();
}
TCP
TCP permission
Be sure to have <uses-permission android:name="android.permission.INTERNET"/> in your AndroidMenifest.xml.
TCP code example
The code below is an example to write in your activity :
new Thread(new Runnable() {
public void run() {
try {
EscPosPrinter printer = new EscPosPrinter(new TcpConnection(ip, port), 203, 65f, 42);
printer.printFormattedTextAndCut(
"[C]<img>" + PrinterTextParserImg.bitmapToHexadecimalString(printer, getApplicationContext().getResources().getDrawab
Related Skills
node-connect
349.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
