Giter Club home page Giter Club logo

nixfull / react-native-pax-library Goto Github PK

View Code? Open in Web Editor NEW

This project forked from moezbaccouche/react-native-pax-library

0.0 0.0 0.0 1.45 MB

A React-Native module which allows the use of native features (Ticket Printing, Opening Cash Drawer, ...) of a Pax Technology Android device through NeptuneLite API.

Home Page: https://www.npmjs.com/package/react-native-pax-library

License: MIT License

JavaScript 10.68% Ruby 7.15% Objective-C 25.47% Java 46.63% Starlark 10.07%

react-native-pax-library's Introduction

react-native-pax-library

A React-Native module which allows the use of native features (Ticket Printing, Opening Cash Drawer, ...) of a Pax Technology Android device through NeptuneLite API.

STILL UNDER DEVELOPMENT

ANDROID ONLY

Installation

Follow carefully the steps below to use this library in your React-Native App

Step 1

Install the package from npm

npm install react-native-pax-library

Step 2

Download the file libDeviceConfig.so

Step 3

In your React-Native app, create a folder named jniLibs and place it inside android/app/src/main

Step 4

Create a folder named armeabi-v7a inside android/app/src/main/jniLibs and place the file libDeviceConfig.so there

Step 5

Open android/app/build.gradle and add the armeabi-v7a filter for the ndk in defaultConfig

...
android {
    ...
    defaultConfig {
        ...
        ndk {
            abiFilters "armeabi-v7a"
        }
    }
}

Step 6

For certain devices like A920Pro you must explicitly add a permission in order to use the printer.

Open AndroidManifest.xml of your React-Native app and add the following line:

  <uses-permission android:name="com.pax.permission.PRINTER" />

Step 7

Run your application

npx react-native run-android

Usage

Printing

You can print a simple text using the method printStr(text:string, cutMode?:number):void

cutMode is an optional parameter to tell the printer how it should cut the paper (partially, fully or no cutting at all) after finishing printing.

If the parameter cutMode is not set then the printer will cut the paper fully.

Full Cut : Pax.FULL_CUT
Partial Cut : Pax.PARTIAL_CUT
No Cutting : Pax.NO_CUT

default: Pax.FULL_CUT

import Pax from "react-native-pax-library";

// ...

Pax.printStr("Hello World", Pax.PARTIAL_CUT);

Opening Cash Drawer

If you have a cash drawer linked to your Pax device, you will be able to open it automatically using the method openDrawer(): Promise<any>

The result returned from this method is a promise that resolves with the result 0 if it succeeds.

// ...

try {
  const result = await Pax.openDrawer();
} catch (error) {
  console.error("Unable to open Cash Drawer.");
}

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

react-native-pax-library's People

Contributors

moezbaccouche avatar

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.