Ionic 2 application to print via Sunmi V1

蹲街弑〆低调 提交于 2019-12-09 13:58: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

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...

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

Thanks.


回答1:


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




回答2:


"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.




回答3:


According to the documentation is not that easy:

http://docs.sunmi.com/htmls/index.html?lang=en##V1%20Docs%20&%20Resources



来源:https://stackoverflow.com/questions/44655755/ionic-2-application-to-print-via-sunmi-v1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!