This package is used in React native projects where only JavaScript is used without TypeScript. If TypeScript is used, please use "npm i react-native-gcprinter"
This is a new React Native project, bootstrapped using @react-native-community/cli
.
Getting Started
Note: Make sure you have completed the React Native - Environment Setup instructions till "Creating a new application" step, before proceeding.
Step 1: Installation
npm install react-native-gcprinter --save
or
yarn add react-native-gcprinter
Step 2: Add dependenceie
- modify app/build.gradle under the android project:
implementation project(':react-native-gcprinter')
Step 3: Add 'GcPrinterPackage' to MainApplication
import com.goodcom.react.GcPrinter.GcPrinterPackage;
...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new GcPrinterPackage()
);
Step 4: Import in React-Native
import GcPrinter from 'react-native-gcprinter';
import { FontSize, AlignmentType, BarcodeType } from 'react-native-gcprinter/gcconstants';
API
Constants
FontSize : font size
AlignmentType : Alignment Type
BarcodeType : Barcode Type
FontSize | Default,Small,Medium,Big,DoubleHeight,DoubleWidth,SmallBold,MediumBold,BigBold,DoubleHeightBold,DoubleWidthBold |
AlignmentType | Left,Center,Right |
BarcodeType | barcodeUpca,barcodeUpce,barcodeEan8,barcodeEan13,barcodeCode128,barcodeCode39,barcodeCodeBar,barcodeItf,barcodeCode93,barcodeQrCode |
Method
drawText | strLeft, fontLeft, strMid, fontMid, strRight, fontRight | null |
printText | isAutoFeed | null |
drawLeftRight | strLeft, fontLeft, strRight, fontRight | null |
drawCustom | string, fontSize, align | null |
drawNewLine | | null |
drawOneLine | fontSize | null |
drawOneLineDefault | | null |
drawBarcode | str, align, type | null |
drawBarcodeWithHeight | string, align, type, height | null |
drawQrCode | string, align | null |
drawQrCodeWithHeight | string,align,height | null |
isDeviceSupport | | Promise<number> |
printJson | json | null |
printImageByBase64 | base64, align, isAutoFeed | null |
printImageByArray | byteArray, align, isAutoFeed | null |
drawText: (strLeft, fontLeft, strMid, fontMid, strRight, fontRight) => {},
printText: (isAutoFeed) => {},
drawLeftRight: (strLeft, fontLeft, strRight, fontRight) => {},
drawCustom: (string, fontSize, align) => {},
drawNewLine: () => {},
drawOneLine: (fontSize) => {},
drawOneLineDefault: () => {},
drawBarcode: (str, align, type) => {},
drawBarcodeWithHeight: (str, align, type, height) => {},
drawQrCode: (string, align) => {};
drawQrCodeWithHeight: (string,align,height) => {};
isDeviceSupport: () => Promise.resolve(''),
printJson: (json) => {},
printImageByBase64: (base64, align, isAutoFeed) => {},