1.2.1 • Published 4 years ago

rn-epson-tm82 v1.2.1

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

react-native-epson-tm82

React-Native plugin for Epson POS printer Model TM-T82 Ethernet (Android Only).

Any questions or bug please raise a issue.

##Still under development

Installation

Step 1

Install via NPM

npm install rn-epson-tm82 --save

or install via Yarn

yarn add rn-epson-tm82 --save

Step 2

Link the plugin to your RN project

react-native link rn-epson-tm82

Or you may need to link manually

on your android/settings.gradle

...
include ':rn-epson-tm82'
project(':rn-epson-tm82').projectDir = new File(rootProject.projectDir, '../node_modules/rn-epson-tm82/android')

on your android/app/build.gradle

...
dependencies{
  ...
  implementation project(':rn-epson-tm82')
}

on your android/app/src/main/java/com/yourpackagename/MainApplication.java

Import Section

import com.nowarzz.rnepson.RNReactNativeEpsonTm82Package;
...

protected List<ReactPackage> getPackages() {
  ...
  ,new RNReactNativeEpsonTm82Package()
}

Step 3

Refers to your JS files

  import TM from 'rn-epson-tm82';

Usage and APIs

Printer

  • initialize ==> To initialize printer configuration
await TM.initialize();

*writeText ==> Add text to printer buffer //TODO: add parameter to customize text

const option = {
  bold: true,
  fontSize:2
}
await TM.writeText("My Label Here",option);

Options for write text

bold

true or false

fontSize

range of 1 to 8. Max 8. Standard usage is between 1 to 2.

*printColumn ==> Split text based on column //TODO: add parameter to customize text

const column = [16,16,16];
const align =[TM.ALIGN_LEFT,TM.ALIGN_CENTER,TM.ALIGN_RIGHT];
await TM.printColumn(column,align,["Align Left","Align Center","Align Right"],{});

*writeQRCode ==> Add QR Code to buffer.

const msg = "QRCODE TEXT";
await TM.writeQRCode(msg);

*writeImage ==> Add image to buffer. Accept only base64 string

const image = "BASE64 encoded string";
await TM.writeImage(image,options);

Options for image

width

label width. height will auto calculate based on image ratio

*writeFeed ==> Add feed to paper

await TM.writeFeed(1);

*writeCut ==> Cut paper

await TM.writeCut();

*startPrint ==> Start printing from the feed to target IP address

await TM.startPrint(ipAddress);

Options for start print

ipAddress

IP Address on String "000.000.000.000" format. Example: "192.168.192.168"

Discovery

*Initialize ==> Initialize Discovery searching

await TM.initializeDiscovery();

*Start Discovery ==> Start to Discover Printer

await TM.startDiscovery();

*Stop Discovery ==> Stop to Discover Printer

await TM.stopDiscovery();

//TODO: add test print script

Demos of printing receipt

await TM.initialize();
await TM.writeText("My Restaurant Cafe\n");
await TM.writeText("------------------------------------------------\n");
const column = [4, 26, 9, 9];
const align = [2, 0, 2, 2];
await TM.printColumn(column, align, [`Qty`, "Item Name", "Price", "Amount"], {});
await TM.writeText("------------------------------------------------\n");
await TM.printColumn(column, align, [`1`, "Rice", "$1.0", "$1.0"], {});
await TM.printColumn(column, align, [`2`, "Ice Water", "$1.0", "$2.0"], {});
await TM.printColumn(column, align, [`3`, "Espresso", "$1.0", "$3.0"], {});
await TM.printColumn(column, align, [`4`, "Banana Split", "$1.0", "$4.0"], {});
await TM.printColumn(column, align, [`5`, "Tenderloin Steak", "$1.0", "$5.0"], {});
await TM.printColumn(column, align, [`6`, "Soup of the day", "$1.0", "$6.0"], {});
await TM.writeText("------------------------------------------------\n");
const totalColumn = [30,18];
const totalAlign = [0,2];
await TM.printColumn(totalColumn,totalAlign,["Total","$21.0"],{});
await TM.writeFeed(2);
await TM.writeText("Thank you. Please come back again");
await TM.startPrint();

For Proguard-Rules

if you are using Proguard on Release, add this syntax to your android/app/proguard-rules.pro

-keep class com.epson.** {*;} 
-dontwarn com.epson.**
1.2.1

4 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago