Saravanan Sachi
Saravanan Sachi

Reputation: 2612

Ionic 2 application to print via Sunmi V1

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.

Upvotes: 0

Views: 7463

Answers (3)

Shareef
Shareef

Reputation: 46

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

Upvotes: 3

Saravanan Sachi
Saravanan Sachi

Reputation: 2612

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

Upvotes: 1

hector narvaez
hector narvaez

Reputation: 21

According to the documentation is not that easy:

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

Upvotes: 0

Related Questions