{"id":15027532,"url":"https://github.com/dantsu/escpos-thermalprinter-android","last_synced_at":"2025-05-15T17:06:22.648Z","repository":{"id":37629311,"uuid":"253709244","full_name":"DantSu/ESCPOS-ThermalPrinter-Android","owner":"DantSu","description":"Useful library to help Android developpers to print with (Bluetooth, TCP, USB) ESC/POS thermal printer.","archived":false,"fork":false,"pushed_at":"2024-05-14T13:06:50.000Z","size":340,"stargazers_count":1320,"open_issues_count":66,"forks_count":397,"subscribers_count":33,"default_branch":"master","last_synced_at":"2025-05-15T17:06:15.297Z","etag":null,"topics":["android","android-library","barcode","bluetooth-printer","escpos","escpos-printer","qrcode","tcp-printer","thermal-printer","thermal-printing","usb-printer"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DantSu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"DantSu"}},"created_at":"2020-04-07T06:42:00.000Z","updated_at":"2025-05-15T15:01:07.000Z","dependencies_parsed_at":"2023-02-09T15:46:40.845Z","dependency_job_id":"21290cf1-b646-4cc6-8e0c-31f650c16b93","html_url":"https://github.com/DantSu/ESCPOS-ThermalPrinter-Android","commit_stats":{"total_commits":110,"total_committers":12,"mean_commits":9.166666666666666,"dds":"0.23636363636363633","last_synced_commit":"f61030e46269319e2d72b938501676420657b9c8"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DantSu%2FESCPOS-ThermalPrinter-Android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DantSu%2FESCPOS-ThermalPrinter-Android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DantSu%2FESCPOS-ThermalPrinter-Android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DantSu%2FESCPOS-ThermalPrinter-Android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DantSu","download_url":"https://codeload.github.com/DantSu/ESCPOS-ThermalPrinter-Android/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254384988,"owners_count":22062422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","barcode","bluetooth-printer","escpos","escpos-printer","qrcode","tcp-printer","thermal-printer","thermal-printing","usb-printer"],"created_at":"2024-09-24T20:06:37.860Z","updated_at":"2025-05-15T17:06:17.640Z","avatar_url":"https://github.com/DantSu.png","language":"Java","funding_links":["https://github.com/sponsors/DantSu"],"categories":[],"sub_categories":[],"readme":"[![Jitpack package repository - ESCPOS-ThermalPrinter-Android v3.3.0](https://jitpack.io/v/DantSu/ESCPOS-ThermalPrinter-Android.svg)](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/3.3.0)\n[![](https://jitpack.io/v/DantSu/ESCPOS-ThermalPrinter-Android/month.svg)](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/3.3.0)\n[![](https://jitpack.io/v/DantSu/ESCPOS-ThermalPrinter-Android/week.svg)](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/3.3.0)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n# Android library for ESC/POS Thermal Printer\n\nUseful library to help Android developers to print with (Bluetooth, TCP, USB) ESC/POS thermal printers.\n\n## ✨ Supporting\n\n⭐ Star this repository to support this project. You will contribute to increase the visibility of this library 🙂\n\n## Table of contents\n\n- [Android version](#android-version)\n- [Tested printers](#tested-printers)\n- [Test It !](#test-it-)\n- [Installation](#installation)\n- [Bluetooth](#bluetooth)\n  - [Bluetooth permission](#bluetooth-permission)\n  - [Bluetooth code example](#bluetooth-code-example)\n- [TCP](#tcp)\n  - [TCP permission](#tcp-permission)\n  - [TCP code example](#tcp-code-example)\n- [USB](#usb)\n  - [USB permission](#usb-permission)\n  - [USB code example](#usb-code-example)\n- [Charset encoding](#charset-encoding)\n- [Formatted text : syntax guide](#formatted-text--syntax-guide)\n- [Class list](#class-list)\n  - [BluetoothPrintersConnections](#user-content-class--comdantsuescposprinterconnectionbluetoothbluetoothprintersconnections)\n  - [UsbPrintersConnections](#user-content-class--comdantsuescposprinterconnectionusbusbprintersconnections)\n  - [EscPosPrinter](#user-content-class--comdantsuescposprinterescposprinter)\n  - [PrinterTextParserImg](#user-content-class--comdantsuescposprintertextparserprintertextparserimg)\n  - [EscPosCharsetEncoding](#user-content-class--comdantsuescposprinterescposcharsetencoding)\n- [Projects using this library](#projects-using-this-library)\n- [Contributing](#contributing)\n\n\n## Android version\n\nDeveloped for SDK version 16 (Android 4.1 Jelly Bean) and above.\n\n\n## Tested printers\n\n1. [HOIN HOP H58 Thermal Printer ESC/POS](https://www.gearbest.com/printers/pp_662658.html).\n2. [XPRINTER XP-P300](https://xprinter.vn/xprinter-xp-p300-may-in-hoa-don-di-dong-bluetooth/).\n3. [MUNBYN IMP001](https://www.munbyn.com/collections/portable-receipt-printer/products/58mm-bluetooth-thermal-printer-imp001).\n4. [JP-Q2 POS Terminal PDA](https://www.aliexpress.com/item/32971775060.html) (Embedded printer is configured as Bluetooth device)\n5. [MUNBYN ITPP047](https://www.munbyn.com/products/munbyn-itpp047-wifi-thermal-printer) (tested over USB)\n\n## Test it !\n\nTo test this library, it's pretty simple !\n\n- Create a directory and open a terminal inside\n- Run `git clone https://github.com/DantSu/ESCPOS-ThermalPrinter-Android.git .`\n- Open the directory with Android Studio\n- Test it !\n\n## Installation\n\n**Step 1.** Add the [JitPack](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/3.3.0) repository to your build file. Add it in your root `/build.gradle` at the end of repositories:\n\n```\nallprojects {\n    repositories {\n        ...\n        maven { url 'https://jitpack.io' }\n    }\n}\n```\n\n**Step 2.** Add the dependency in `/app/build.gradle` :\n\n```\ndependencies {\n    ...\n    implementation 'com.github.DantSu:ESCPOS-ThermalPrinter-Android:3.3.0'\n}\n```\n\n## Bluetooth\n\n### Bluetooth permission\n\nBe sure to have `\u003cuses-permission android:name=\"android.permission.BLUETOOTH\" /\u003e`, `\u003cuses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\" /\u003e`, `\u003cuses-permission android:name=\"android.permission.BLUETOOTH_CONNECT\" /\u003e`, `\u003cuses-permission android:name=\"android.permission.BLUETOOTH_SCAN\" /\u003e` in your `AndroidManifest.xml`.\n\nAlso, you have to check the bluetooth permission in your app like this :\n\n```java\nif (android.os.Build.VERSION.SDK_INT \u003c android.os.Build.VERSION_CODES.S \u0026\u0026 ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH) != PackageManager.PERMISSION_GRANTED) {\n    ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH}, MainActivity.PERMISSION_BLUETOOTH);\n} else if (android.os.Build.VERSION.SDK_INT \u003c android.os.Build.VERSION_CODES.S \u0026\u0026 ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_ADMIN) != PackageManager.PERMISSION_GRANTED) {\n    ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH_ADMIN}, MainActivity.PERMISSION_BLUETOOTH_ADMIN);\n} else if (android.os.Build.VERSION.SDK_INT \u003e= android.os.Build.VERSION_CODES.S \u0026\u0026 ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {\n    ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH_CONNECT}, MainActivity.PERMISSION_BLUETOOTH_CONNECT);\n} else if (android.os.Build.VERSION.SDK_INT \u003e= android.os.Build.VERSION_CODES.S \u0026\u0026 ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_SCAN) != PackageManager.PERMISSION_GRANTED) {\n    ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH_SCAN}, MainActivity.PERMISSION_BLUETOOTH_SCAN);\n} else {\n    // Your code HERE\n}\n```\n\n### Bluetooth code example\n\nThe code below is an example to write in your activity :\n\n```java\nEscPosPrinter printer = new EscPosPrinter(BluetoothPrintersConnections.selectFirstPaired(), 203, 48f, 32);\nprinter\n    .printFormattedText(\n        \"[C]\u003cimg\u003e\" + PrinterTextParserImg.bitmapToHexadecimalString(printer, this.getApplicationContext().getResources().getDrawableForDensity(R.drawable.logo, DisplayMetrics.DENSITY_MEDIUM))+\"\u003c/img\u003e\\n\" +\n        \"[L]\\n\" +\n        \"[C]\u003cu\u003e\u003cfont size='big'\u003eORDER N°045\u003c/font\u003e\u003c/u\u003e\\n\" +\n        \"[L]\\n\" +\n        \"[C]================================\\n\" +\n        \"[L]\\n\" +\n        \"[L]\u003cb\u003eBEAUTIFUL SHIRT\u003c/b\u003e[R]9.99e\\n\" +\n        \"[L]  + Size : S\\n\" +\n        \"[L]\\n\" +\n        \"[L]\u003cb\u003eAWESOME HAT\u003c/b\u003e[R]24.99e\\n\" +\n        \"[L]  + Size : 57/58\\n\" +\n        \"[L]\\n\" +\n        \"[C]--------------------------------\\n\" +\n        \"[R]TOTAL PRICE :[R]34.98e\\n\" +\n        \"[R]TAX :[R]4.23e\\n\" +\n        \"[L]\\n\" +\n        \"[C]================================\\n\" +\n        \"[L]\\n\" +\n        \"[L]\u003cfont size='tall'\u003eCustomer :\u003c/font\u003e\\n\" +\n        \"[L]Raymond DUPONT\\n\" +\n        \"[L]5 rue des girafes\\n\" +\n        \"[L]31547 PERPETES\\n\" +\n        \"[L]Tel : +33801201456\\n\" +\n        \"[L]\\n\" +\n        \"[C]\u003cbarcode type='ean13' height='10'\u003e831254784551\u003c/barcode\u003e\\n\" +\n        \"[C]\u003cqrcode size='20'\u003ehttps://dantsu.com/\u003c/qrcode\u003e\"\n    );\n```\n\nBelow a picture of the receipt printed with the code above :\n\n![Example of a printed receipt](https://dantsu.com/files/receipt-thermal-printer.png?1)\n\n## TCP\n\n### TCP permission\n\nBe sure to have `\u003cuses-permission android:name=\"android.permission.INTERNET\"/\u003e` in your `AndroidManifest.xml`.\n\n### TCP code example\n\nThe code below is an example to write in your activity :\n\n```java\nnew Thread(new Runnable() {\n    public void run() {\n        try {\n            EscPosPrinter printer = new EscPosPrinter(new TcpConnection(\"192.168.1.3\", 9300, 15), 203, 48f, 32);\n            printer\n                .printFormattedText(\n                    \"[C]\u003cimg\u003e\" + PrinterTextParserImg.bitmapToHexadecimalString(printer, getApplicationContext().getResources().getDrawableForDensity(R.drawable.logo, DisplayMetrics.DENSITY_MEDIUM)) + \"\u003c/img\u003e\\n\" +\n                    \"[L]\\n\" +\n                    \"[C]\u003cu\u003e\u003cfont size='big'\u003eORDER N°045\u003c/font\u003e\u003c/u\u003e\\n\" +\n                    \"[L]\\n\" +\n                    \"[C]================================\\n\" +\n                    \"[L]\\n\" +\n                    \"[L]\u003cb\u003eBEAUTIFUL SHIRT\u003c/b\u003e[R]9.99e\\n\" +\n                    \"[L]  + Size : S\\n\" +\n                    \"[L]\\n\" +\n                    \"[L]\u003cb\u003eAWESOME HAT\u003c/b\u003e[R]24.99e\\n\" +\n                    \"[L]  + Size : 57/58\\n\" +\n                    \"[L]\\n\" +\n                    \"[C]--------------------------------\\n\" +\n                    \"[R]TOTAL PRICE :[R]34.98e\\n\" +\n                    \"[R]TAX :[R]4.23e\\n\" +\n                    \"[L]\\n\" +\n                    \"[C]================================\\n\" +\n                    \"[L]\\n\" +\n                    \"[L]\u003cfont size='tall'\u003eCustomer :\u003c/font\u003e\\n\" +\n                    \"[L]Raymond DUPONT\\n\" +\n                    \"[L]5 rue des girafes\\n\" +\n                    \"[L]31547 PERPETES\\n\" +\n                    \"[L]Tel : +33801201456\\n\" +\n                    \"[L]\\n\" +\n                    \"[C]\u003cbarcode type='ean13' height='10'\u003e831254784551\u003c/barcode\u003e\\n\" +\n                    \"[C]\u003cqrcode size='20'\u003ehttps://dantsu.com/\u003c/qrcode\u003e\"\n                );\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n    }\n}).start();\n```\n\n## USB\n\n### USB permission\n\nBe sure to have `\u003cuses-feature android:name=\"android.hardware.usb.host\" /\u003e` in your `AndroidManifest.xml`.\n\nYou have to check the USB permission in your app like this :\n\n```java\nprivate static final String ACTION_USB_PERMISSION = \"com.android.example.USB_PERMISSION\";\nprivate final BroadcastReceiver usbReceiver = new BroadcastReceiver() {\n    public void onReceive(Context context, Intent intent) {\n        String action = intent.getAction();\n        if (MainActivity.ACTION_USB_PERMISSION.equals(action)) {\n            synchronized (this) {\n                UsbManager usbManager = (UsbManager) getSystemService(Context.USB_SERVICE);\n                UsbDevice usbDevice = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);\n                if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {\n                    if (usbManager != null \u0026\u0026 usbDevice != null) {\n                        // YOUR PRINT CODE HERE\n                    }\n                }\n            }\n        }\n    }\n};\n\npublic void printUsb() {\n    UsbConnection usbConnection = UsbPrintersConnections.selectFirstConnected(this);\n    UsbManager usbManager = (UsbManager) this.getSystemService(Context.USB_SERVICE);\n    if (usbConnection != null \u0026\u0026 usbManager != null) {\n        PendingIntent permissionIntent = PendingIntent.getBroadcast(\n            this,\n            0,\n            new Intent(MainActivity.ACTION_USB_PERMISSION),\n            android.os.Build.VERSION.SDK_INT \u003e= android.os.Build.VERSION_CODES.S ? PendingIntent.FLAG_MUTABLE : 0\n        );\n        IntentFilter filter = new IntentFilter(MainActivity.ACTION_USB_PERMISSION);\n        registerReceiver(this.usbReceiver, filter);\n        usbManager.requestPermission(usbConnection.getDevice(), permissionIntent);\n    }\n}\n```\n\n### USB code example\n\nThe code below is an example to write in your activity :\n\n```java\nEscPosPrinter printer = new EscPosPrinter(new UsbConnection(usbManager, usbDevice), 203, 48f, 32);\nprinter\n    .printFormattedText(\n        \"[C]\u003cimg\u003e\" + PrinterTextParserImg.bitmapToHexadecimalString(printer, this.getApplicationContext().getResources().getDrawableForDensity(R.drawable.logo, DisplayMetrics.DENSITY_MEDIUM))+\"\u003c/img\u003e\\n\" +\n        \"[L]\\n\" +\n        \"[C]\u003cu\u003e\u003cfont size='big'\u003eORDER N°045\u003c/font\u003e\u003c/u\u003e\\n\" +\n        \"[L]\\n\" +\n        \"[C]================================\\n\" +\n        \"[L]\\n\" +\n        \"[L]\u003cb\u003eBEAUTIFUL SHIRT\u003c/b\u003e[R]9.99e\\n\" +\n        \"[L]  + Size : S\\n\" +\n        \"[L]\\n\" +\n        \"[L]\u003cb\u003eAWESOME HAT\u003c/b\u003e[R]24.99e\\n\" +\n        \"[L]  + Size : 57/58\\n\" +\n        \"[L]\\n\" +\n        \"[C]--------------------------------\\n\" +\n        \"[R]TOTAL PRICE :[R]34.98e\\n\" +\n        \"[R]TAX :[R]4.23e\\n\" +\n        \"[L]\\n\" +\n        \"[C]================================\\n\" +\n        \"[L]\\n\" +\n        \"[L]\u003cfont size='tall'\u003eCustomer :\u003c/font\u003e\\n\" +\n        \"[L]Raymond DUPONT\\n\" +\n        \"[L]5 rue des girafes\\n\" +\n        \"[L]31547 PERPETES\\n\" +\n        \"[L]Tel : +33801201456\\n\" +\n        \"[L]\\n\" +\n        \"[C]\u003cbarcode type='ean13' height='10'\u003e831254784551\u003c/barcode\u003e\\n\" +\n        \"[C]\u003cqrcode size='20'\u003ehttps://dantsu.com/\u003c/qrcode\u003e\"\n    );\n```\n\n\n## Charset encoding\n\nTo change charset encoding of the printer, use `EscPosCharsetEncoding` class :\n\n```java\nEscPosPrinter printer = new EscPosPrinter(deviceConnection, 203, 48f, 32, new EscPosCharsetEncoding(\"windows-1252\", 16));\n```\n\n`escPosCharsetId` may change with printer model.\n[Follow this link to find `escPosCharsetId` that works with many printers](https://www.epson-biz.com/modules/ref_escpos/index.php?content_id=32)\n\n## Formatted text : syntax guide\n\n### New line\n\nUse `\\n` to create a new line of text.\n\n### Text alignment and column separation\n\nAdd an alignment tag on a same line of text implicitly create a new column.\n\nColumn alignment tags :\n\n- `[L]` : left side alignment\n- `[C]` : center alignment\n- `[R]` : right side alignment\n\nExample :\n\n- `[L]Some text` : One column aligned to left\n- `[C]Some text` : One column aligned to center\n- `[R]Some text` : One column aligned to right\n- `[L]Some text[L]Some other text` : Two columns aligned to left. `Some other text` starts in the center of the paper.\n- `[L]Some text[R]Some other text` : Two columns, first aligned to left, second aligned to right. `Some other text` is printed at the right of paper.\n- `[L]Some[R]text[R]here` : Three columns.\n- `[L][R]text[R]here` : Three columns. The first is empty but it takes a third of the available space.\n\n### Font\n\n#### Size\n\n`\u003cfont\u003e\u003c/font\u003e` tag allows you to change the font size and color. Default size is `normal` / `black`.\n\n- `\u003cfont size='normal'\u003eSome text\u003c/font\u003e` : Normal size\n- `\u003cfont size='wide'\u003eSome text\u003c/font\u003e` : Double width of medium size\n- `\u003cfont size='tall'\u003eSome text\u003c/font\u003e` : Double height of medium size\n- `\u003cfont size='big'\u003eSome text\u003c/font\u003e` : Double width and height of medium size\n- `\u003cfont size='big-2'\u003eSome text\u003c/font\u003e` : 3 x width and height\n- `\u003cfont size='big-3'\u003eSome text\u003c/font\u003e` : 4 x width and height\n- `\u003cfont size='big-4'\u003eSome text\u003c/font\u003e` : 5 x width and height\n- `\u003cfont size='big-5'\u003eSome text\u003c/font\u003e` : 6 x width and height\n- `\u003cfont size='big-6'\u003eSome text\u003c/font\u003e` : 7 x width and height\n\n- `\u003cfont color='black'\u003eSome text\u003c/font\u003e` : black text - white background\n- `\u003cfont color='bg-black'\u003eSome text\u003c/font\u003e` : white text - black background\n- `\u003cfont color='red'\u003eSome text\u003c/font\u003e` : red text - white background (Not working on all printer)\n- `\u003cfont color='bg-red'\u003eSome text\u003c/font\u003e` : white text - red background (Not working on all printer)\n\n#### Bold\n\n`\u003cb\u003e\u003c/b\u003e` tag allows you to change the font weight.\n\n- `\u003cb\u003eSome text\u003c/b\u003e`\n\n#### Underline\n\n`\u003cu\u003e\u003c/u\u003e` tag allows you to underline the text.\n\n- `\u003cu\u003eSome text\u003c/u\u003e` text underlined\n- `\u003cu type='double'\u003eSome text\u003c/u\u003e` text double-strike (Not working on all printer)\n\n### Image\n\n`\u003cimg\u003e\u003c/img\u003e` tag allows you to print image. Inside the tag you need to write a hexadecimal string of an image.\n\nUse `PrinterTextParserImg.bitmapToHexadecimalString` to convert `Drawable`, `BitmapDrawable` or `Bitmap` to hexadecimal string.\n\n- `\u003cimg\u003e`hexadecimal string of an image`\u003c/img\u003e`\n\n**⚠ WARNING ⚠** : This tag has several constraints :\n\n- A line that contains `\u003cimg\u003e\u003c/img\u003e` can have only one alignment tag and it must be at the beginning of the line.\n- `\u003cimg\u003e` must be directly preceded by nothing or an alignment tag (`[L][C][R]`).\n- `\u003c/img\u003e` must be directly followed by a new line `\\n`.\n- You can't write text on a line that contains `\u003cimg\u003e\u003c/img\u003e`.\n- Maximum height of printed image is 256px, If you want to print larger bitmap. Please refer to this solution: [#70](https://github.com/DantSu/ESCPOS-ThermalPrinter-Android/issues/70#issuecomment-714390014)\n\n### Barcode\n\n`\u003cbarcode\u003e\u003c/barcode\u003e` tag allows you to print a barcode. Inside the tag you need to write the code number to print.\n\n- `\u003cbarcode\u003e451278452159\u003c/barcode\u003e` : **(12 numbers)**  \nPrints a EAN13 barcode (height: 10mm, width: ~70% printer width, text: displayed below).\n- `\u003cbarcode type='ean8'\u003e4512784\u003c/barcode\u003e` : **(7 numbers)**  \nPrints a EAN8 barcode (height: 10mm, width: ~70% printer width, text: displayed below).\n- `\u003cbarcode type='upca' height='20'\u003e4512784521\u003c/barcode\u003e` : **(11 numbers)**  \nPrints a UPC-A barcode (height: 20mm, width: ~70% printer width, text: displayed below).\n- `\u003cbarcode type='upce' height='25' width='50' text='none'\u003e512789\u003c/barcode\u003e` : **(6 numbers)**  \nPrints a UPC-E barcode (height: 25mm, width: ~50mm, text: hidden).\n- `\u003cbarcode type='128' width='40' text='above'\u003eDantSu\u003c/barcode\u003e` : **(string)**  \nPrints a barcode 128 (height: 10mm, width: ~40mm, text: displayed above).\n\n**⚠ WARNING ⚠** : This tag has several constraints :\n\n- A line that contains `\u003cbarcode\u003e\u003c/barcode\u003e` can have only one alignment tag and it must be at the beginning of the line.\n- `\u003cbarcode\u003e` must be directly preceded by nothing or an alignment tag (`[L][C][R]`).\n- `\u003c/barcode\u003e` must be directly followed by a new line `\\n`.\n- You can't write text on a line that contains `\u003cbarcode\u003e\u003c/barcode\u003e`.\n\n### QR Code\n\n`\u003cqrcode\u003e\u003c/qrcode\u003e` tag allows you to print a QR code. Inside the tag you need to write the QR code data.\n\n- `\u003cqrcode\u003ehttps://dantsu.com/\u003c/qrcode\u003e` :\nPrints a QR code with a width and height of 20 millimeters.\n- `\u003cqrcode size='25'\u003e123456789\u003c/qrcode\u003e` :\nPrints a QR code with a width and height of 25 millimeters.\n\n**⚠ WARNING ⚠** : This tag has several constraints :\n\n- A line that contains `\u003cqrcode\u003e\u003c/qrcode\u003e` can have only one alignment tag and it must be at the beginning of the line.\n- `\u003cqrcode\u003e` must be directly preceded by nothing or an alignment tag (`[L][C][R]`).\n- `\u003c/qrcode\u003e` must be directly followed by a new line `\\n`.\n- You can't write text on a line that contains `\u003cqrcode\u003e\u003c/qrcode\u003e`.\n\n## Class list\n\n### Class : `com.dantsu.escposprinter.connection.bluetooth.BluetoothPrintersConnections`\n\n#### **Static** Method : `selectFirstPaired()`\nEasy way to get the first bluetooth printer paired / connected.\n- **return** `BluetoothConnection`\n\n#### Method : `getList()`\nGet a list of bluetooth printers.\n- **return** `BluetoothConnection[]`\n\n⚠️ If the arrray returned by `getList()` does not contain you printer or if `selectFirstPaired()` does not return your printer. Read this issue : https://github.com/DantSu/ESCPOS-ThermalPrinter-Android/issues/80#issuecomment-729759832\n\n### Class : `com.dantsu.escposprinter.connection.tcp.TcpConnection`\n\n#### Constructor : `TcpConnection(String address, int port[, int timeout])`\n- **param** `String address` : Targeted ip address\n- **param** `int port` : Targeted tcp port\n- **param** `int timeout` *(optional)* : Connection timeout (default : 30)\n\n### Class : `com.dantsu.escposprinter.connection.usb.UsbPrintersConnections`\n\n#### **Static** Method : `selectFirstConnected()`\nEasy way to get the first USB printer connected.\n- **return** `UsbConnection`\n\n#### Method : `getList()`\nGet a list of USB printers.\n- **return** `UsbConnection[]`\n\n### Class : `com.dantsu.escposprinter.EscPosPrinter`\n\n#### Constructor : `EscPosPrinter(DeviceConnection printer, int printerDpi, float printingWidthMM, int nbrCharactersPerLine [, EscPosCharsetEncoding charsetEncoding])`\n- **param** `DeviceConnection printer` : Instance of a connected printer\n- **param** `int printerDpi` : DPI of the connected printer\n- **param** `float printerWidthMM` : Printing width in millimeters\n- **param** `int printerNbrCharactersPerLine` : The maximum number of medium sized characters that can be printed on a line.\n- **param** `EscPosCharsetEncoding charsetEncoding` *(optional)* : Set the charset encoding.\n\n#### Method : `disconnectPrinter()`\nClose the connection with the printer.\n- **return** `Printer` : Fluent interface\n\n#### Method : `getNbrCharactersPerLine()`\nGet the maximum number of characters that can be printed on a line.\n- **return** `int`\n\n#### Method : `getPrinterWidthMM()`\nGet the printing width in millimeters\n- **return** `float`\n\n#### Method : `getPrinterDpi()`\nGet the printer DPI\n- **return** `int`\n\n#### Method : `getPrinterWidthPx()`\nGet the printing width in dot\n- **return** `int`\n\n#### Method : `getPrinterCharSizeWidthPx()`\nGet the number of dot that a printed character contain\n- **return** `int`\n\n#### Method : `mmToPx(float mmSize)`\nConvert the mmSize variable from millimeters to dot.\n- **param** `float mmSize` : Distance in millimeters to be converted\n- **return** `int` : Dot size of mmSize.\n\n#### Method : `useEscAsteriskCommand(boolean enable)`\nActive \"ESC *\" command for image printing.\n- **param** `boolean enable` : true to use \"ESC *\", false to use \"GS v 0\"\n- **return** `Printer` : Fluent interface\n\n#### Method : `printFormattedText(String text)`\nPrint a formatted text and feed paper (20 millimeters). Read the [\"Formatted Text : Syntax guide\" section](#formatted-text--syntax-guide) for more information about text formatting options.\n- **param** `String text` : Formatted text to be printed.\n- **return** `Printer` : Fluent interface\n\n#### Method : `printFormattedTextAndCut(String text)`\nPrint a formatted text, feed paper (20 millimeters) and cut the paper. Read the [\"Formatted Text : Syntax guide\" section](#formatted-text--syntax-guide) for more information about text formatting options.\n- **param** `String text` : Formatted text to be printed.\n- **return** `Printer` : Fluent interface\n\n#### Method : `printFormattedText(String text, float mmFeedPaper)`\nPrint a formatted text and feed paper (`mmFeedPaper` millimeters). Read the [\"Formatted Text : Syntax guide\" section](#formatted-text--syntax-guide) for more information about text formatting options.\n- **param** `String text` : Formatted text to be printed.\n- **param** `float mmFeedPaper` : Millimeter distance feed paper at the end.\n- **return** `Printer` : Fluent interface\n\n#### Method : `printFormattedTextAndCut(String text, float mmFeedPaper)`\nPrint a formatted text, feed paper (`mmFeedPaper` millimeters) and cut the paper. Read the [\"Formatted Text : Syntax guide\" section](#formatted-text--syntax-guide) for more information about text formatting options.\n- **param** `String text` : Formatted text to be printed.\n- **param** `float mmFeedPaper` : Millimeter distance feed paper at the end.\n- **return** `Printer` : Fluent interface\n\n#### Method : `printFormattedTextAndOpenCashBox(String text, float mmFeedPaper)`\nPrint a formatted text, feed paper (`mmFeedPaper` millimeters), cut the paper and open the cash box. Read the [\"Formatted Text : Syntax guide\" section](#formatted-text--syntax-guide) for more information about text formatting options.\n- **param** `String text` : Formatted text to be printed.\n- **param** `float mmFeedPaper` : Millimeter distance feed paper at the end.\n- **return** `Printer` : Fluent interface\n\n#### Method : `printFormattedText(String text, int dotsFeedPaper)`\nPrint a formatted text and feed paper (`dotsFeedPaper` dots). Read the [\"Formatted Text : Syntax guide\" section](#formatted-text--syntax-guide) for more information about text formatting options.\n- **param** `String text` : Formatted text to be printed.\n- **param** `int dotsFeedPaper` : Distance feed paper at the end.\n- **return** `Printer` : Fluent interface\n\n#### Method : `printFormattedTextAndCut(String text, int dotsFeedPaper)`\nPrint a formatted text, feed paper (`dotsFeedPaper` dots) and cut the paper. Read the [\"Formatted Text : Syntax guide\" section](#formatted-text--syntax-guide) for more information about text formatting options.\n- **param** `String text` : Formatted text to be printed.\n- **param** `int dotsFeedPaper` : Distance feed paper at the end.\n- **return** `Printer` : Fluent interface\n\n#### Method : `printFormattedTextAndOpenCashBox(String text, int dotsFeedPaper)`\nPrint a formatted text, feed paper (`dotsFeedPaper` dots), cut the paper and open the cash box. Read the [\"Formatted Text : Syntax guide\" section](#formatted-text--syntax-guide) for more information about text formatting options.\n- **param** `String text` : Formatted text to be printed.\n- **param** `int dotsFeedPaper` : Distance feed paper at the end.\n- **return** `Printer` : Fluent interface\n\n#### Method : `bitmapToBytes(Bitmap bitmap, boolean gradient)`\nConvert Bitmap object to ESC/POS image.\n- **param** `Bitmap bitmap` : Instance of Bitmap\n- **param** `boolean gradient` : `false` Black and white image, `true` Grayscale image\n- **return** `byte[]` : Bytes contain the image in ESC/POS command\n\n### Class : `com.dantsu.escposprinter.textparser.PrinterTextParserImg`\n\n#### **Static** Method : `bitmapToHexadecimalString(Printer printer, Drawable drawable [, boolean gradient])`\nConvert Drawable instance to a hexadecimal string of the image data.\n- **param** `Printer printer` : A Printer instance that will print the image.\n- **param** `Drawable drawable` : Drawable instance to be converted.\n- **param** `boolean gradient` *(optional)* : `false` Black and white image, `true` Grayscale image (Default : `true`)\n- **return** `String` : A hexadecimal string of the image data. Empty string if Drawable cannot be cast to BitmapDrawable.\n\n#### **Static** Method : `bitmapToHexadecimalString(Printer printer, BitmapDrawable bitmapDrawable [, boolean gradient])`\nConvert BitmapDrawable instance to a hexadecimal string of the image data.\n- **param** `Printer printer` : A Printer instance that will print the image.\n- **param** `BitmapDrawable bitmapDrawable` : BitmapDrawable instance to be converted.\n- **param** `boolean gradient` *(optional)* : `false` Black and white image, `true` Grayscale image (Default : `true`)\n- **return** `String` : A hexadecimal string of the image data.\n\n#### **Static** Method : `bitmapToHexadecimalString(Printer printer, Bitmap bitmap [, boolean gradient])`\nConvert Bitmap instance to a hexadecimal string of the image data.\n- **param** `Printer printer` : A Printer instance that will print the image.\n- **param** `Bitmap bitmap` : Bitmap instance to be converted.\n- **param** `boolean gradient` *(optional)* : `false` Black and white image, `true` Grayscale image (Default : `true`)\n- **return** `String` : A hexadecimal string of the image data.\n\n#### **Static** Method : `bytesToHexadecimalString(byte[] bytes)`\nConvert byte array to a hexadecimal string of the image data.\n- **param** `byte[] bytes` : Bytes contain the image in ESC/POS command.\n- **return** `String` : A hexadecimal string of the image data.\n\n#### **Static** Method : `hexadecimalStringToBytes(String hexString)`\nConvert hexadecimal string of the image data to bytes ESC/POS command.\n- **param** `String hexString` : Hexadecimal string of the image data.\n- **return** `byte[]` : Bytes contain the image in ESC/POS command.\n\n### Class : `com.dantsu.escposprinter.EscPosCharsetEncoding`\n\n#### Constructor : `EscPosCharsetEncoding(String charsetName, int escPosCharsetId)`\n- **param** `charsetName` Name of charset encoding (Ex: ISO-8859-1)\n- **param** `escPosCharsetId` Id of charset encoding for your printer (Ex: 6)\n\n## Projects using this library\n\n- [AllInOneYT/react-native-thermal-printer : A React Native bridge](https://github.com/AllInOneYT/react-native-thermal-printer)\n- [paystory-de/thermal-printer-cordova-plugin : A Cordova / Ionic bridge](https://github.com/paystory-de/thermal-printer-cordova-plugin)\n- [asukiaaa/react-native-escpos-android : A React Native bridge](https://github.com/asukiaaa/react-native-escpos-android)\n- [android_bluetooth_printer : A Flutter bridge](https://pub.dev/packages/android_bluetooth_printer)\n\n## Contributing\n\nPlease fork this repository and contribute back using pull requests.\n\nAny contributions, large or small, major features, bug fixes, are welcomed and appreciated but will be thoroughly reviewed\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdantsu%2Fescpos-thermalprinter-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdantsu%2Fescpos-thermalprinter-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdantsu%2Fescpos-thermalprinter-android/lists"}