| Expo | ✅
| React Native CLI | ✅
| Flutter | ✅
Implement | Android | IOS |
---|---|---|
Base64 | ✅ | ✅ |
Label | contact | contact |
multiple print | contact | contact |
XPrinter | ✅ | ✅ |
ZyWell | ✅ | ✅ |
Printer | Android | IOS |
---|---|---|
BLEPrinter | ✅ | ✅ |
NetPrinter | ✅ | ✅ |
USB | ✅ | coming soon |
Watch the video on YouTube test multiple printing
npm i react-native-savanitdev-thermal-printer
or
yarn add react-native-savanitdev-thermal-printer
Print Columns Text
npm i esc-pos-encoder-savanitdev
import EscPosEncoder from "esc-pos-encoder-savanitdev";
import { Buffer } from "buffer";
useEffect(() => {
if (Platform.OS === "android") {
onCreate();
}
}, []);
const printRaw = () => {
let encoder = new EscPosEncoder();
let result = encoder
.table(
[
{ width: 36, marginRight: 2, align: "left" },
{ width: 10, align: "right" },
],
[
["Item 1", "€ 10,00"],
["Item 2", "15,00"],
["Item 3", "9,95"],
["Item 4", "4,75"],
["Item 5", "211,05"],
["", "=".repeat(10)],
["Total", (encoder) => encoder.bold().text("€ 250,75").bold()],
]
)
.encode();
const base64string = Buffer.from(result).toString("base64");
printRawData(base64string, "your ip printer");
};
Print image
const printImg = () => {
if (Platform.OS === "android") {
// for IOS if you got error when print image please check your size of your image it's just limit 10-20mb
printImgNet("192.168.1.xxx", "your image base64string");
} else {
// for android
printImgNet("192.168.1.xxx", "your image base64string", 576, 576);
}
};
Print Loop different IP printer
// example for IOS
const printLoop = () => {
for (let i = 0; i < ListIPPrinter.length; i++) {
const res = ListIPPrinter[i];
connectNet(res.ip)
.then((e: any) => {
printTest(res.ip);
})
.catch((err: any) => {
// do something
});
}
};
// example for android
const printLoop = () => {
for (let i = 0; i < ListIPPrinter.length; i++) {
const res = ListIPPrinter[i];
await new Promise((resolve) => {
connectNet(res.ip_address)
.then((e) => {
setTimeout(() => {
printImgBase64(base64, 576, 576)
.finally(() => {
disConnect(res.ip_address);
setTimeout(resolve, 500);
})
.catch((e) => {
console.log("error print =>", e);
});
}, 500);
})
.catch((err) => {
setTimeout(resolve, 0);
});
});
}
};
you can contact me directly Telegram, feedback your problem
or ✉️
Telegram : @dev_la Fanpage : https://www.facebook.com/SavanitDev
Thank you guys