Closed saravanacs closed 5 years ago
Please anyone help me, Using Cordova sunmi printer is working fine. But, i need Printer status before printing. Example, Validate printer status, Don't allow to do printer is not available and not ready or paper not available.
Thanks in Advance
Hi @saravanacs What is the SUNMI device you are using? I can only verify on sunmi V1.
@tmalbonph Hi sir, i use Sunmi V1
@tmalbonph Hi sir, i use Sunmi V1
@tmalbonph I write below code for printing data, but before printing check printer is available and above mentioned validations
checkPrint(data) { /try { //this.printerInfo = sunmiInnerPrinter.hasPrinter(); sunmiInnerPrinter.printerInit(); sunmiInnerPrinter.printTextWithFont('\nABC Computers \nABC Computers \nABC Computers \nABC Computers \nABC Computers \nABC Computers \nABC Computers \nABC Computers \nABC Computers \nABC Computers \nABC Computers \nABC Computers \nABC Computers \nABC Computers \nABC Computers ', 'Calibri', 36); if (JSON.stringify(sunmiInnerPrinter) !== "{}") { this.printerInfo = JSON.stringify(sunmiInnerPrinter); return; } this.printerInfo = sunmiInnerPrinter.hasPrinter(); // it is safe to use sunmiInnerPrinter here } catch (err) { this.printerInfo = ("error: " + JSON.stringify(err.message)); }/ try {
var address = data.BranchAddress; //var name = "Saravana Kumar. M" var receiptNo = data.ReceiptNo; var subscriberName = data.SubscriberName; var receivedAmount = data.ReceivedAmount; var pendingAmount = data.PendingAmount; var advanceAmount = data.AdvanceAmount; var paymentMode = data.PaymentMode; var collectionAgent = data.PreparedBy; var group = data.Group; sunmiInnerPrinter.printString("Receipt No: "+receiptNo+ "\n"+"Date : "+'20-09-2019'); sunmiInnerPrinter.printTextWithFont('\n\t Test Pvt.Ltd ', 'Segoe UI Black', 32); sunmiInnerPrinter.printString("\n\t"+address+"\n"); sunmiInnerPrinter.printTextWithFont('\nName : '+subscriberName, 'Arial Black', 30); sunmiInnerPrinter.printString("\n------------------------------\n"+"Group : "+group+"\n"+"Received Amount : Rs. "+receivedAmount+"\n"+"Pending Amount : Rs. "+pendingAmount + "\n"+ "Advance Amount : Rs."+advanceAmount+"\n"+"Payment Mode : "+paymentMode+"\n"+"------------------------------"+"\n"+"* System generated Bill."+"\n"+"\t Prepared by : "+collectionAgent+"\n"+"No Signature Needed\n"+"\n\t\t\t\t\tThank You ..!!\n\n"+"\n\n") } catch (err) { this.printerInfo = ("error: " + JSON.stringify(err.message)); } }
@tmalbonph https://github.com/tmalbonph/cordova-plugin-sunmi-inner-printer
In this link, where is located printer status code( i mean file location) sir
@tmalbonph https://github.com/tmalbonph/cordova-plugin-sunmi-inner-printer
In this link, where is located printer status code( i mean file location) sir
You will need to use the plugin entry here: cordova-plugin-sunmi-inner-printer/www/innerprinter.js
For example
printString: function (text, resolve, reject) {
exec(resolve, reject, "Printer", "printString", [text]);
},
there is a resolve
and reject
parameter entry, at reject callback, you can detect status of the printer being printed in progress. That is the only reliable way to check for the status.
printString: function (text, resolve, reject) { exec(resolve, reject, "Printer", "printString", [text]); },
Where i put this code sir. I posted my print function code above . Please edit that code sir and send me where set resolve and reject functionality
printString: function (text, resolve, reject) { exec(resolve, reject, "Printer", "printString", [text]); },
Where i put this code sir. I posted my print function code above . Please edit that code sir and send me where set resolve and reject functionality
It is not that simple, You need to code at a minimum of 120-550 lines of code to make the robust printing code works on SUNMI V1 using Javascript. More codes if your using ionic3+
If you want to get your hands dirty; you need to digest my suggestion from top to bottom on this thread here: https://github.com/labibramadhan/cordova-sunmi-inner-printer/issues/14
@tmalbonph for above link, cordova plugin printer using check printer is available. If i use this steps for get printer status ? is it possible sir ?
@tmalbonph for above link, cordova plugin printer using check printer is available. If i use this steps for get printer status ? is it possible sir ?
Yes that is the basic idea, as I have mention on top of this thread, you need to provide both the resolve
and reject
callback to monitor status of your printer and the data your application is printing.
Please anyone help me, Using Cordova sunmi printer is working fine. But, i need Printer status before printing. Example, Validate printer status, Don't allow to do printer is not available and not ready or paper not available.
Thanks in Advance