Ionic 2 application to print via Sunmi V1

2019-04-17 06:15发布

For an ionic 2 app to print using Sunmi V1, added native plugin for printer by executing

cordova plugin add cordova-plugin-printer

First I checked whether the printer is available by

checkPrinter() {
    this.printer.check().then(function () {
        alert("Printer available");
    }, function () {
        alert("Printer not available");
    });
}

It alerts "Printer available"

But the below method doesn't prompt any message

printData() {
    this.printer.isAvailable().then(function () {
        this.printer.print("Test Data").then(function () {
            alert("Printed");
        }, function () {
            alert("Printing error");
        });
    }, function () {
        alert('Unavailable');
    });
}

So I called Printer.print method directly as below

printData(){
    this.printer.print("Test Data").then(function () {
        alert("Printed");
    }, function () {
        alert("Printing Error");
    });
}

This method opens Print dialog to choose printer

enter image description here

If I select 'All Printers' from the dropdown to select printer instead of 'Save as PDF', then the search screen appears and keeps on searching...

enter image description here

Is some configuration missing or is it possible to interact with POS printers using cordova printer plugin?

Thanks.

3条回答
SAY GOODBYE
2楼-- · 2019-04-17 06:38
一夜七次
3楼-- · 2019-04-17 06:43

i found a new plugin created by labibramadhan. Thanks labib

you can find the plugin here

https://github.com/labibramadhan/cordova-sunmi-inner-printer

First, install by typing ionic

cordova plugin add https://github.com/labibramadhan/cordova-sunmi-inner-printer.git

Then, use it on your cordova javascript codes by calling:

window.sunmiInnerPrinter.printOriginalText("Hello World!")

window.sunmiInnerPrinter.[methods available on here]

https://github.com/labibramadhan/cordova-sunmi-inner-printer/blob/master/www/innerprinter.js

Thank you

查看更多
Fickle 薄情
4楼-- · 2019-04-17 06:55

"Sunmi printer itself is not a network printer, web applications can not communicate directly with the printer, you need to accept data on the android applications" - From the documents available in their site. (I also contacted their support team but there was no proper reply)

As of now it doesn't support, so I am using github.com/shangmisunmi/SunmiPrinterDemo as example and developing the application in Android instead of ionic 2.

查看更多
登录 后发表回答