通过Sunmi V1打印的Ionic 2应用程序 [英] Ionic 2 application to print via Sunmi V1

查看:1442
本文介绍了通过Sunmi V1打印的Ionic 2应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于使用Sunmi V1打印的离子2应用程序,通过执行

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");
    });
}

警告打印机可用

但是下面的方法不会提示任何消息

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');
    });
}

所以我直接调用了Printer.print方法,如下所示

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

如果从下拉列表中选择所有打印机以选择打印机而不是'保存为PDF',然后出现搜索屏幕并继续搜索...

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

是否缺少某些配置或是否可以使用cordova打印机插件与POS打印机进行交互?

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

谢谢。

推荐答案

我发现了一个由labibramadhan创建的新插件。谢谢labib

i found a new plugin created by labibramadhan. Thanks labib

你可以在这里找到插件

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

首先,通过输入ionic来安装

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

谢谢

这篇关于通过Sunmi V1打印的Ionic 2应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆