npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

epsonepos2tmp20

v0.0.6

Published

epsonepos2tmp20 ==================== Cordova plugin for Epson ePOS SDK(v2.6.0) for iOS and Android.

Downloads

120

Readme

epsonepos2tmp20

Cordova plugin for Epson ePOS SDK(v2.6.0) for iOS and Android.

Integrates the Epson ePOS2 SDK for iOS and Android with a limited set of functions to discover and connect ePOS printers

Check supported devices and requirements from official SDK by Epson.

Install

cordova plugin add epsonepos2tmp20

API

The plugin exposes an interface object to cordova.epos2 for direct interaction with the SDK functions. See www/plugin.js for details about the available functions and their arguments. All API functions are asynchronous and return a Promise.

Printer Discovery

.startDiscover(discoverCallback)

This will search for supported printers connected to your mobiel device via Bluetooth or available in local area network (LAN)

cordova.epos2.startDiscover((deviceInfo) => {
    // success callback with deviceInfo
    console.log(deviceInfo);
}, (error) => {
    // error callback
    console.err(error);
});

.stopDiscover()

cordova.epos2.stopDiscover()
  .then(() => {
    // success callback
  })
  .catch((error) => {
    // error callback
  });

.getSupportedModels()

Resolves with an array of strings denoting the supported printer models.

cordova.epos2.getSupportedModels()
  .then((models) => {
    // success callback
    console.log(models);
  })
  .catch((error) => {
    // error callback
    console.err(error);
  });

Printer Connection

.connectPrinter(device, printerModel)

Establish a connection to the given printer device. For device either provide a device information objects as retrieved from discovery or string with device address ('BT:xx:xx:xx:xx:xx' or 'TCP:xx.xx.xx.xx').

cordova.epos2.connectPrinter(device, printerModel)
  .then((connected) => {
    // success callback
    console.log(connected);
  })
  .catch(function(error) {
    // error callback
    console.err(error);
  });

.disconnectPrinter()

cordova.epos2.disconnectPrinter()
  .then((disconnected) => {
    // success callback
    console.log(disconnected);
  })
  .catch((error) => {
    // error callback
    console.err(error);
  });

.getPrinterStatus()

cordova.epos2.getPrinterStatus()
  .then((status) => {
    // success callback with status object
    console.log(status);
  })
  .catch((error) => {
    // error callback
    console.err(error);
  });

Set the printer language

Let the language of the printer or text before printing. EPOS2_MODEL_ANK and EPOS2_LANG_EN are default.

Available languages for lang (model language) are:

  • EPOS2_MODEL_ANK,
  • EPOS2_MODEL_CHINESE
  • EPOS2_MODEL_TAIWANAN
  • EPOS2_MODEL_KOREAN
  • EPOS2_MODEL_THAI
  • EPOS2_MODEL_SOUTHASIA

For textLang:

  • EPOS2_LANG_EN
  • EPOS2_LANG_JA
  • EPOS2_LANG_ZH_CN
  • EPOS2_LANG_ZH_TW
  • EPOS2_LANG_KO
  • EPOS2_LANG_TH
  • EPOS2_LANG_VI
  • EPOS2_LANG_MULTI
  • EPOS2_PARAM_DEFAULT
cordova.epos2.setLang(lang, textLang)
  .then(function(status) {
    // status=true if language was set
    console.log(status);
  })
  .catch(function(error) {
    // error callback
  });

Printing

.print(stringData, successCallback, errorCallback)

One-shot function printing the given text. Use '\n' in string data in order to move to next line. Cut feed is added automatically.

cordova.epos2.print(stringData, () => {
    // success callback
}, (error) => {
    // error callback
});

.printText(stringData, textFont, textSize, textAlign, terminate)

Send text to the connected printer. Also accepts parameters for font type, text size and alignment. Can be called multiple times for additional text lines. Set terminate to True in order to complete the print job and add cut feed.

cordova.epos2.printText(stringData, 0, 1, 2, false)
  .then(() => {
    // success callback
  })
  .catch((error) => {
    // error callback
  });

.printBarCode(data, type, hriPosition,hriFont,Bwidth,Bheight,terminate)

Print different types of barcodes. Please refer to the Epson SDK documentation for correctly encoding the data.

Types:

  • EPOS2_BARCODE_UPC_A
  • EPOS2_BARCODE_UPC_E
  • EPOS2_BARCODE_EAN133
  • EPOS2_BARCODE_JAN133
  • EPOS2_BARCODE_EAN8
  • EPOS2_BARCODE_JAN8,
  • EPOS2_BARCODE_CODE39
  • EPOS2_BARCODE_ITF
  • EPOS2_BARCODE_CODABAR
  • EPOS2_BARCODE_CODE93
  • EPOS2_BARCODE_CODE128
  • EPOS2_BARCODE_GS1_128
  • EPOS2_BARCODE_GS1_DATABAR_OMNIDIRECTIONAL
  • EPOS2_BARCODE_GS1_DATABAR_TRUNCATED
  • EPOS2_BARCODE_GS1_DATABAR_LIMITED
  • EPOS2_BARCODE_GS1_DATABAR_EXPANDED

Function parameters:

  • @param {String} Barcode Data String, Encode Data or Specify start character
  • @param {String} Type Type of barcode
  • @param {Number} Specifies the HRI position.(0 - 3) 0:No print 1:above 2:below 3:both
  • @param {Number} Specifies the HRI font. (0 - 4)
  • @param {Number} Specifies the width of a single module in dots. (2-6)
  • @param {Number} Specifies the height of the barcode in dots. (1 - 255)
  • @param {Boolean} [terminate=false] Send additional line feeds an a "cut" command to complete the print
  • @return {Promise} resolving on success, rejecting on error

Example

cordova.epos2.printBarCode("123456789011", "EPOS2_BARCODE_EAN13", 0,0,2,70, true)
.then(res => console.debug(res))
.catch(e => console.error(e))

.printSymbol(data, type, level, width, height, size,terminate)

Print different types of symbols like QR codes. Please refer to the Epson SDK documentation for correctly encoding the data.

Types:

  • EPOS2_SYMBOL_PDF417_STANDARD
  • EPOS2_SYMBOL_PDF417_TRUNCATED
  • EPOS2_SYMBOL_QRCODE_MODEL_1
  • EPOS2_SYMBOL_QRCODE_MODEL_2
  • EPOS2_SYMBOL_QRCODE_MICRO
  • EPOS2_SYMBOL_MAXICODE_MODE_2
  • EPOS2_SYMBOL_MAXICODE_MODE_3
  • EPOS2_SYMBOL_MAXICODE_MODE_5
  • EPOS2_SYMBOL_MAXICODE_MODE_6
  • EPOS2_SYMBOL_GS1_DATABAR_STACKED
  • EPOS2_SYMBOL_GS1_DATABAR_STACKED_OMNIDIRECTIONAL
  • EPOS2_SYMBOL_GS1_DATABAR_EXPANDED_STACKED
  • EPOS2_SYMBOL_AZTECCODE_FULLRANGE
  • EPOS2_SYMBOL_AZTECCODE_COMPACT
  • EPOS2_SYMBOL_DATAMATRIX_SQUARE
  • EPOS2_SYMBOL_DATAMATRIX_RECTANGLE_8
  • EPOS2_SYMBOL_DATAMATRIX_RECTANGLE_12
  • EPOS2_SYMBOL_DATAMATRIX_RECTANGLE_16

Level parameters:

  • EPOS2_LEVEL_0
  • EPOS2_LEVEL_1
  • EPOS2_LEVEL_2
  • EPOS2_LEVEL_3
  • EPOS2_LEVEL_4
  • EPOS2_LEVEL_5
  • EPOS2_LEVEL_6
  • EPOS2_LEVEL_7
  • EPOS2_LEVEL_8
  • EPOS2_PARAM_DEFAULT
  • EPOS2_LEVEL_L
  • EPOS2_LEVEL_M
  • EPOS2_LEVEL_Q
  • EPOS2_LEVEL_H

Example

cordova.epos2.printSymbol("https://github.com/MarkChu/cordova-plugin-epson-epos2-tm-p20", "EPOS2_SYMBOL_QRCODE_MODEL_2", "EPOS2_PARAM_DEFAULT", 5,5,0, true)
.then(res => console.debug(res))
.catch(e => console.error(e))

.printBarCode128(data, type, hriPosition,hriFont,Bwidth,Bheight,terminate)

Helper function to print barcode 128 CODEB

cordova.epos2.printBarCode128("11111", 0,0,2,70, true).then(res => console.debug(res)).catch(e => console.error(e))

.printImage(data, printMode, halfTone, terminate)

Send image data as data-url to the connected printer.

cordova.epos2.printImage(imageSource, 0, 0, false)
  .then(() => {
    // success callback
  })
  .catch((error) => {
    // error callback
  });

Example

After successful discovery or entering the printer address, one can send a print job like this:

cordova.epos2.connectPrinter(device, model)
  .then(function() {
    return cordova.epos2.printText([
      'This is a printing demo from Cordova\n',
      'Composed using the cordova-plugin-epos2 plugin\n',
      '\n'
    ]);
  })
  .then(function() {
    // send image with `terminate` flag to complete the print job
    return cordova.epos2.printImage('data:image/png;base64,xxxxx', 0, 0, true);
  })
  .then(function() {
    return cordova.epos2.disconnectPrinter()
      .catch(function() { /* ignore disconnect errors */ });
  })
  .then(function() {
    console.log('Printing complete.');
  })
  .catch(function(err) {
    console.error('Printing failed', err);
  })

Platforms

  • iOS 9+
  • Android

License

MIT License