https://github.com/m1ga/ti.thermalprinter
ESC/POS thermal printer library for Titanium (Android)
https://github.com/m1ga/ti.thermalprinter
android mobile titanium-mobile titanium-module
Last synced: 9 months ago
JSON representation
ESC/POS thermal printer library for Titanium (Android)
- Host: GitHub
- URL: https://github.com/m1ga/ti.thermalprinter
- Owner: m1ga
- License: other
- Created: 2021-11-29T20:37:52.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-07-21T15:57:23.000Z (almost 4 years ago)
- Last Synced: 2025-07-19T12:42:43.982Z (9 months ago)
- Topics: android, mobile, titanium-mobile, titanium-module
- Language: Java
- Homepage:
- Size: 458 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ti.Thermalprinter - ESC/POS thermal printer library for Titanium (Android)
Appcelerator Titanium library that implements https://github.com/DantSu/ESCPOS-ThermalPrinter-Android to print with (Bluetooth, TCP, USB) ESC/POS thermal printer
## Installation
* `ti.thermalprinter` in tiapp.xml
* add this to your build.gradle:
```
repositories {
maven { url 'https://jitpack.io' }
}
```
* `const ThermalPrinter = require("ti.thermalprinter")`
## Constants
* TYPE_BLUETOOTH
* TYPE_TCP
* TYPE_USB
## Methods
* `requestPermissions()`
* `print({connection, text, [ip, port, timeout, dpi, width, cpl});`
* `connection`: TYPE_BLUETOOTH | TYPE_TCP | TYPE_USB
* `text`: actual text. See https://github.com/DantSu/ESCPOS-ThermalPrinter-Android#formatted-text--syntax-guide for syntax
if `connection` is `TYPE_TCP` you have to set:
* `ip` (String), `port`, `dpi`, `width` and `cpl` (characters per line)
* `getUSBList()` prints a list of connected USB devices to the console. Only for debug at the moment
* `scanPrinters()` prints a list of BLE devices to the console. Only for debug at the moment
## Example
```js
const ThermalPrinter = require("ti.thermalprinter");
ThermalPrinter.print({
connection: ThermalPrinter.TYPE_BLUETOOTH,
text: "[C]================================\n" +
"[L]\n" +
"[L]Customer :\n" +
"[L]User name\n" +
"[L]Street No 7\n" +
"[L]1234 place\n" +
"[L]Tel : +123456\n" +
"[L]\n" +
"[C]http://www.migaweb.de/"
});
```
## TODO
* add support for images
* add "getList" to select a different printer. Currently it will use the first one
## Author
* Michael Gangolf (@MichaelGangolf / Web)