react-native-printer
A React Native Library to support USB/BLE/Net printer for Android platform
Installation
npm install react-native-printer --save
Integrate module
To integrate react-native-printer
with the rest of your react app just execute:
react-native link react-native-printer
Usage
; USBPrinterUSBPrinter
Example
USBPrinter
Printer structure:
{
device_name: '/usb/lp1',
vendor_id: 1155,
product_id: 22304,
}
{ ifPlatformOS == 'android' USBPrinter } { ifthisstatecurrentPrinter USBPrinter; else console } { ifthisstatecurrentPrinter USBPrinter; else console } ... { return <View style=stylescontainer> thisstateprinters <TouchableOpacity onPress= this> <Text> Print Text </Text> </TouchableOpacity> <TouchableOpacity onPress= this> <Text> Print Bill Text </Text> </TouchableOpacity> </View> } ...
BLEPrinter
Printer structure:
{
device_name: '内部打印机',
inner_mac_address: 'XXXXX-XXXXXXXX',
}
{ ifPlatformOS == 'android' USBPrinter } { ifPlatformOS == 'android' //connect printer USBPrinter } { ifthisstatecurrentPrinter USBPrinter; else console } { ifthisstatecurrentPrinter USBPrinter; else console } ... { return <View style=stylescontainer> thisstateprinters <TouchableOpacity onPress= this> <Text> Print Text </Text> </TouchableOpacity> <TouchableOpacity onPress= this> <Text> Print Bill Text </Text> </TouchableOpacity> </View> } ...
NetPrinter
Printer structure:
{
device_name: "192.168.10.241:9100",
host: '192.168.10.241',
port: 9100
}
{ ifPlatformOS == 'android' NetPrinter } { ifPlatformOS == 'android' //connect printer NetPrinter } { ifthisstatecurrentPrinter NetPrinter; else console } { ifthisstatecurrentPrinter NetPrinter; else console } ... { return <View style=stylescontainer> thisstateprinters <TouchableOpacity onPress= this> <Text> Print Text </Text> </TouchableOpacity> <TouchableOpacity onPress= this> <Text> Print Bill Text </Text> </TouchableOpacity> </View> } ...