Skip to content

Commit 5a62032

Browse files
committed
add readme for npm
1 parent abddc8e commit 5a62032

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed

package/README.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<p align="center">
2+
<img src="./docs/assets/printer.png"
3+
alt="Printer"
4+
/>
5+
</p>
6+
7+
| [![npm version](https://badge.fury.io/js/react-native-esc-pos-printer.svg)](https://badge.fury.io/js/react-native-esc-pos-printer) |
8+
|---|
9+
10+
## Features
11+
- Supports **BLE, LAN, USB** and **Wi-Fi** connection methods
12+
- Print receipts natively and from React Native views
13+
- Compatible with the **new architecture**
14+
- Build-in **queue mechanism**
15+
- **Clear errors descriptions**
16+
- Proxy-like API makes it **easy to add new commands**
17+
18+
19+
## Installation
20+
21+
### React Native
22+
23+
> [!WARNING]
24+
> For react-native lower than 0.76.x version, use react-native-esc-pos-printer 4.3.3 or lower
25+
26+
```sh
27+
yarn add react-native-esc-pos-printer
28+
```
29+
30+
### Expo
31+
32+
```sh
33+
npx expo install react-native-esc-pos-printer
34+
npx expo prebuild
35+
```
36+
37+
### Also complete [this required steps](./docs/INSTALLATION.md)
38+
39+
## Usage
40+
41+
### Discover printers
42+
43+
```tsx
44+
import { usePrintersDiscovery } from 'react-native-esc-pos-printer';
45+
46+
function App() {
47+
const { start, isDiscovering, printers } =
48+
usePrintersDiscovery();
49+
50+
useEffect(() => {
51+
start();
52+
}, []);
53+
}
54+
```
55+
56+
### Print
57+
58+
```tsx
59+
import { Printer } from 'react-native-esc-pos-printer';
60+
61+
function App() {
62+
const { start, isDiscovering, printers } =
63+
usePrintersDiscovery();
64+
65+
useEffect(() => {
66+
start();
67+
}, []);
68+
69+
const print = () => {
70+
// printing on all discovered printers
71+
printers.forEach(printersData => {
72+
const printerInstance = new Printer({
73+
target: printersData.target,
74+
deviceName: printersData.deviceName,
75+
});
76+
77+
const res = await printerInstance.addQueueTask(async () => {
78+
await Printer.tryToConnectUntil(
79+
printerInstance,
80+
(status) => status.online.statusCode === PrinterConstants.TRUE
81+
);
82+
await printerInstance.addText('DUDE!');
83+
await printerInstance.addFeedLine();
84+
await printerInstance.addCut();
85+
const result = await printerInstance.sendData();
86+
await printerInstance.disconnect();
87+
return result;
88+
})
89+
})
90+
}
91+
92+
return <Button title="Print" onPress={print} />;
93+
}
94+
95+
```
96+
97+
## Documentation
98+
1. [Discovery API](./docs/discovery/discovery.md)
99+
2. [Printer API](./docs/printer/Printer.md)
100+
3. [Examples](./docs/QUICK_START.md)
101+
4. [Supported devices](./docs/SUPPORTED_DEVICES.md)
102+
5. [SDK information (v2.27.0)](./docs/SDK.md)
103+
104+
## Sponsor this project
105+
If you like what I'm doing and want to support me, you can:
106+
107+
<p align="left">
108+
<a href="https://buymeacoffee.com/tr3v3r" target="_blank">
109+
<img width="500" src="./docs/assets/coffee.png" alt="Buy me a coffee" />
110+
</a>
111+
</p>
112+
113+
## Known issues
114+
115+
1. It's not possible to print and discover on Android simulator.
116+
117+
2. If you have an issue with using Flipper on iOS real device, [try this](./docs/flipperWorkaround.md) workaround.
118+
119+
## License
120+
121+
MIT

0 commit comments

Comments
 (0)