2017-06-20 38 views
0

對於離子2應用程序中使用李宣美V1打印,增加了對打印機本地插件通過執行離子2應用程序通過李宣美V1打印

cordova plugin add cordova-plugin-printer 

首先我檢查打印機是否可用由

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

它提醒「打印機可用」

但以下方法不提示任何消息

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

於是我就打電話Printer.print直接的方法如下

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

此方法打開打印對話框中選擇打印機

enter image description here

如果我選擇「所有打印機」從下拉菜單中選擇打印機,而不是'保存爲PDF',然後搜索屏幕出現,並繼續搜索...

enter image description here

是否缺少一些配置或者是否可以與使用cordova打印機插件的POS打印機進行交互?

謝謝。

回答

1

「李宣美打印機本身不是一個網絡打印機,網絡應用程序無法與打印機進行直接通信,必須接受在Android數據應用程序「 - 從他們網站上提供的文件。 (我也聯繫了他們的支持團隊,但沒有得到適當的答覆)

截至目前它不支持,所以我使用github.com/shangmisunmi/SunmiPrinterDemo作爲例子,並在Android中開發應用程序而不是離子2 。

+0

感謝演示鏈接:) – mohnage7

0
+0

謝謝,但我已經檢查了所有這些文件,即使我聯繫了支持。「Sunmi打印機本身不是網絡打印機,Web應用程序不能直接與打印機通信,你需要接受android應用程序上的數據」=>截至目前它不支持,所以我使用https:// github .com/shangmisunmi/SunmiPrinterDemo爲例,並在Android中進行開發。 –

0

我發現了一個由labibramadhan創建的新插件。由於拉比卜

,你可以在這裏找到該插件

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

首先,通過鍵入離子

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

然後安裝,使用它在您的科爾多瓦的JavaScript代碼通過調用:

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

window.sunmiInnerPrinter.[methods available on here] 

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

謝謝

相關問題