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

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

问题描述

对于使用商米 V1 打印的 ionic 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

然后,通过调用在您的cordova javascript代码上使用它:

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

谢谢

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

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