Comments (2)
Thanks @thiendangit
I have solved the issue by adding setTimeout with each method and incrementing on every use.
asyncPrintText = (text, waitTime) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
this.Printer.printText(text);
resolve();
}, waitTime * 100);
});
};
asyncPrintBill = (bill, waitTime) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
this.Printer.printBill(bill);
resolve();
}, waitTime * 100);
});
};
asyncPrintColumnsText = (
columnHeader,
columnWidth,
columnAliment,
columnStyle,
waitTime,
) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
this.Printer.printColumnsText(
columnHeader,
columnWidth,
columnAliment,
columnStyle,
);
resolve();
}, waitTime * 100);
});
};
I am using like below
printBillOrderInfo = () => {
return new Promise((resolve, reject) => {
const paymentMethod = this.order?.method
? orderPaymentMethods?.[this.order.method] !== undefined
? orderPaymentMethods?.[this.order.method]
: ' - '
: ' - ';
const userName =
this.order?.user?.name !== null ? this.order?.user?.name : ' - ';
const pickupMethod = orderPickupMethods?.[this.order.action];
const orderRemark = this.order?.note !== null ? this.order?.note : ' - ';
const orderDate = codoDateformat(this.order?.create_at);
Promise.all([
printerService.asyncPrintColumnsText(
['Order Id : ', `${this.order?.order_number}`],
[23, 23],
[ColumnAliment.LEFT, ColumnAliment.RIGHT],
['', ''],
this.waitTime++,
),
printerService.asyncPrintColumnsText(
['Method : ', `${pickupMethod}`],
[23, 23],
[ColumnAliment.LEFT, ColumnAliment.RIGHT],
['', ''],
this.waitTime++,
),
printerService.asyncPrintColumnsText(
['Payment Method : ', `${paymentMethod}`],
[23, 23],
[ColumnAliment.LEFT, ColumnAliment.RIGHT],
['', ''],
this.waitTime++,
),
printerService.asyncPrintColumnsText(
['Note : ', `${orderRemark}`],
[23, 23],
[ColumnAliment.LEFT, ColumnAliment.RIGHT],
['', ''],
this.waitTime++,
),
printerService.asyncPrintColumnsText(
['User : ', `${userName}`],
[23, 23],
[ColumnAliment.LEFT, ColumnAliment.RIGHT],
['', ''],
this.waitTime++,
),
printerService.asyncPrintColumnsText(
['Order Date : ', `${orderDate}`],
[23, 23],
[ColumnAliment.LEFT, ColumnAliment.RIGHT],
['', ''],
this.waitTime++,
),
printerService.asyncPrintColumnsText(
[`${DOUBLE_DASHED_LINE}`],
[52],
[ColumnAliment.LEFT],
[''],
this.waitTime++,
),
]).then(() => {
resolve();
});
});
};
from react-native-thermal-receipt-printer-image-qr.
@codoffer try to using setTimeOut in asyncPrintColumnsText function!
asyncPrintColumnsText = (
columnHeader,
columnWidth,
columnAliment,
columnStyle,
) => {
return new Promise((resolve, reject) => {
setTimeOut(()=>{
this.Printer.printColumnsText(
columnHeader,
columnWidth,
columnAliment,
columnStyle,
);
resolve();
}, 100)
});
};
from react-native-thermal-receipt-printer-image-qr.
Related Issues (20)
- printer HOT 1
- Android: Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference
- when usein NetPrinter found White lines printImageBase64 HOT 11
- There is a space between each letter.
- Add codepage to iOS
- speed printImage when using bluetooth thermal printer on iOS very slow HOT 2
- can't install on IOS using expo 48 HOT 5
- Hi Everyone, I can't use function printImageBase64. Warn: not defind this function. I use it in IOS Device. HOT 1
- About the "printColumnsText" method HOT 1
- is it possible to print two images on one row?
- NetPrinter not working well for iOS
- How to get a Printer Status like Connected, Page over, printed, Error(printer not working) or any related status for printer. HOT 1
- libPrinterSDK.a(GCDAsyncSoket.o)
- Trying to connect Network Printer Getting null object reference HOT 1
- Android 13 iMin USB printer permission error
- Could not determine the dependencies of task ':react-native-thermal-receipt-printer-image-qr:compileDebugAidl'. HOT 2
- Multiple device App connect to Printer not support HOT 3
- Cannot reconnect after physical disconnect HOT 1
- Permission error on Android v12+ HOT 2
- The print order results do not match with BLEPrinter HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-thermal-receipt-printer-image-qr.