Giter Club home page Giter Club logo

rn-epson-tm82's Introduction

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.**

rn-epson-tm82's People

Stargazers

 avatar  avatar

Watchers

 avatar

rn-epson-tm82's Issues

Getting deviceInfo from startDiscovery()

Hello @nowarzz !

This isn't so much of an issue as a more general question.

The startPrint() object requires an ipAddress (or theoretically a bluetooth address or usb device address). How is this being obtained? In theory it should be coming from:

await TM.startDiscovery();

where you could do something like

const device = await TM.startDiscovery();

But that doesn't seem to be possible, as you're just returning a response with true or false basically. Are there any React event listeners you're making use of, or is it possible to retrieve the device from the actual startDiscovery() call?

Support for x86 architecture

Hi, thanks to support this great library for community.
But i need help to implementation to my apps.

Problem:
when i'm running in x86 architecture, i got this error
Screenshot_1567999355

Probably cause:
i found that jniLibs doesn't have x86 support in this library. can you tell me how i can get this x86 support ?

regards.
Thanks to your attention

missing strip tool

Task :rn-epson-tm82:stripDebugDebugSymbols
Unable to strip library '/home/piarachmayati/React Native/printEpson/node_modules/rn-epson-tm82/android/build/intermediates/merged_native_libs/debug/out/lib/armeabi/libeposeasyselect.so' due to missing strip tool for ABI 'ARMEABI'. Packaging it as is.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.