[英]Access printer from ionic2
我想知道。 是否有任何選項可以從 ionic 2 實現打印/連接打印機。是否有任何用於打印的cordova 插件。 我遇到了這個插件。
任何有關這方面的幫助/信息都會有用。有沒有辦法訪問 Ionic 2 中的第三方庫。??
在 Ionic 2 中,您可以使用帶有 Cordova 打印機插件的 Ionic Native 打印到 PDF 文件或真正的紙張。要遵循的步驟很簡單。 首先添加用於打印的 Cordova 插件
cordova plugin add https://github.com/katzer/cordova-plugin-printer.git
下一個導入類
import {Printer, PrintOptions} from 'ionic-native';
然后將此方法添加到您的類中
print(){
Printer.isAvailable().then(function(){
Printer.print("https://www.techiediaries.com").then(function(){
alert("printing done successfully !");
},function(){
alert("Error while printing !");
});
}, function(){
alert('Error : printing is unavailable on your device ');
});
}
要測試該方法,請在模板中添加一個按鈕
<button class="button" (click)="print()">Print</button>
你可以在這里找到完整的教程
Cordova 打印插件,
cordova plugin add cordova-plugin-printer
cordova 插件添加 cordova-plugin-printer 或特定版本:
cordova plugin add cordova-plugin-printer@VERSION
然后執行:
cordova build
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.