0.1.3 • Published 12 months ago
react-native-thermal-printer-module v0.1.3
react-native-tx-printer-module
Module for thermal printer command,Only work on android platform
Installation
npm install react-native-tx-printer-module
For react native Expo project, eject/prebuild is required for use of this plugin
->npx expo run:android
Usage
import { TxPrintingModule } from 'react-native-tx-printer-module';
// ...
<Button onPress={
() => {
TxPrintingModule.init();
TxPrintingModule.setFeed(30);
TxPrintingModule.setAlign("CENTER");
TxPrintingModule.setBarcodeHeight(90);
TxPrintingModule.setBarcodeWidth(20);
TxPrintingModule.setBarcodeFontLocation("DOWN")
TxPrintingModule.printBarcode("UPCA", "12345678901");
TxPrintingModule.setFeed(40);
TxPrintingModule.setFontSize(2, 2);
TxPrintingModule.outputStringLine("This is text print with stringline");
TxPrintingModule.setFeed(30);
TxPrintingModule.resetFont();
TxPrintingModule.printImage("/a1.png");
TxPrintingModule.setFontUnderline(true);
TxPrintingModule.setFontBold(true);
TxPrintingModule.setFontType("A");
TxPrintingModule.setFontRotate(true);
TxPrintingModule.setAlign("RIGHT");
TxPrintingModule.setChineseMode(true);
TxPrintingModule.setLineSpacing(1);
TxPrintingModule.outputString("测试")
TxPrintingModule.resetFont();
TxPrintingModule.setChineseMode(false)
TxPrintingModule.setUpsideDown(true)
TxPrintingModule.setCharacterRotate("RIGHT");
TxPrintingModule.outputString("Test margin");
TxPrintingModule.setFeed(30);
TxPrintingModule.setFeedReverse(20);
TxPrintingModule.printQRCode(9, "M", "google.com");
TxPrintingModule.setFeed(30);
TxPrintingModule.printBase64Image("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAH8AAAB/CAMAAADxY+0hAAAAYFBMVEUiLTqzusC2vcO7wsgfKjgTITAYJTMWIzIRHy8bJzUOHS2mrbQoMj+VnKOfpqxIUFpYYGktN0NTW2R3foYAFSdpcHleZm9xeYGNlJw7RE+ss7mHjpV+ho5CS1UADCIyPEcttN8eAAAD4klEQVRoge2a25arIAyGURAEi1qP1er0/d9yQ8+zZlSwibMv/C9mrenNF5IQMIGQXbt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XYew/RcnEPJoj4IEgO83S52GD+TLSYv5OrE2b4lx9nHnDdHwT9bABkgbt844DZdxGQl67fNb8DvjyfGfhrfjIdI9OtZioQG7GXbxyQTRsgkU7+b/xmOgH9Hpmu5LfTFUi0G/BnvkUwz94n/zxdAZXnK5tV/JkKjF39r3y98/8j/j8ikTUaoJoNmAAAAABJRU5ErkJggg==");
TxPrintingModule.CutPaper("PURECUT_FULL");
TxPrintingModule.close();
}
}
title="Test"
color="#841584"
/>
Command Usage
```
init() -> Initilize printer command,must be call on start
setFeed(int length) -> Set paper feed length, 1=0.125mm , max value=255
setAlign(String alignment) -> Set text alignment, Available option = LEFT,CENTER,RIGHT
setBarcodeHeight(int height) -> Set the height of barcode
setBarcodeWidth(int width) -> Set the width of barcode
setBarcodeFontLocation(String location) -> Set the location for display barcode content,Available option = NONE,UP,DOWN,BOTH
printBarcode(String type, String content) -> Print the barcode out, require 2 parameter. First parameter is the TYPE ,second parameter is the barcode content. Available option for TYPE : UPCA,UPCE,EAN13,EAN8,CODE39,ITF,CODABAR,CODE93,CODE128
setFontSize(int width, int height) -> Set the font size of text ,require 2 parameter.First is width,second is height. Available value=1 - 8
outputStringLine(String text) -> Print text content with line space at the end of content
resetFont() -> Reset the font setting
printImage(String path) -> Print image, noted that the image path is start from the application folder. Eg. if path=abc.png, the file need to put at android/data/com.example.app/files/abc.png
printBase64Image(String base64) -> Print base64 image
setFontUnderline(Boolean option) -> Set underline text,Available option:true,false
setFontBold(Boolean option) -> Set bold text,Available option:true,false
setFontType(String type) -> Set font type,Available option:A,B
setFontRotate(Boolean option) -> Set font rotate 90 degree, Available option:true,false
setChineseMode(Boolean option) -> Set this to true if want print chinese text.Available option:true,false
setLineSpacing(int space) -> Set line spacing of text
outputString(String text) -> Print text without line spacing at end of content
setUpsideDown(Boolean option) ->Set to print the content in upside down,Available option:true,false
setCharacterRotate(String option) ->Set to print the content in rotating form.Availble option:NONE,LEFT,RIGHT
setFeedReverse(int length) -> Feed the paper in reverse form,mean going upside.Lenght: 1=0.125mm , max value=255
printQRCode(int size, string err_correct, string content) -> Print QR code.3 parameter is require.First is the size of QR code,second is the error correction level of QR code,third is content of QR code. Option for size: 3-9. Option for error correction level:L,M,Q,H
CutPaper(String option) -> Command to cut the paper.Option: CUT_FULL,CUT_PARTIAL,PURECUT_FULL,PURECUT_PARTIAL. CUT= cut paper depend on black mark.PURECUT= direct cut paper after content. FULL= Fully cut the paper(Paper will drop down from printer). PARTIAL=Partially cut the paper(Paper remain on printer,need to pull it)
close() -> Close the printer command,must run at the end of command
```
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Made with create-react-native-library