Skip to content

Latest commit

 

History

History
62 lines (46 loc) · 2.01 KB

README.md

File metadata and controls

62 lines (46 loc) · 2.01 KB

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

  • <module>ti.thermalprinter</module> 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});

    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

const ThermalPrinter = require("ti.thermalprinter");
ThermalPrinter.print({
  connection: ThermalPrinter.TYPE_BLUETOOTH,
  text: "[C]================================\n" +
        "[L]\n" +
        "[L]<font size='tall'>Customer :</font>\n" +
        "[L]User name\n" +
        "[L]Street No 7\n" +
        "[L]1234 place\n" +
        "[L]Tel : +123456\n" +
        "[L]\n" +
        "[C]<qrcode size='20'>http://www.migaweb.de/</qrcode>"
});

TODO

  • add support for images
  • add "getList" to select a different printer. Currently it will use the first one

Author

Buy Me A Coke donate button