[英]@ionic-native/printer is not working
I have used @ionic-native/printer plugin to implement printing option for bill report. 我已经使用@ ionic-native / printer插件来实现账单报告的打印选项。
I have installed plugin using this command line: 我已经使用以下命令行安装了插件:
npm install --save @ionic-native/printer
Then in the viewbill.html I put a line to active the printer : 然后在viewbill.html中放置一行以激活打印机:
<button ion-button (click)="print()">
<ion-icon name="print">
</ion-icon>
Print
</button>
Then my viewbill.ts code: 然后我的viewbill.ts代码:
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, Platform, AlertController } from 'ionic-angular';
import { Printer, PrintOptions } from '@ionic-native/printer';
@IonicPage()
@Component({
selector: 'page-viewbill',
templateUrl: 'viewbill.html',
})
export class ViewbillPage {
public srNo = [];
public particulars = [];
public particularAmt = [];
constructor(public navCtrl: NavController,
public navParams: NavParams,
public printer: Printer,
public platform: Platform,
public alertCtrl: AlertController) {
}
ionViewDidLoad() {
console.log('ionViewDidLoad ViewbillPage');
this.srNo = [
{no: '1'},
{no: '2'},
{no: '3'}
];
this.particulars = [
{particular: 'Particular 1'},
{particular: 'Particular 2'},
{particular: 'Particular 3'}
];
this.particularAmt = [
{amount: '100'},
{amount: '500'},
{amount: '1000'}
];
}
print(){
if(this.platform.is('cordova')){
if(this.printer.isAvailable())
{
let options: PrintOptions = {
name: 'Bill Report',
duplex: true,
landscape: true,
grayscale: true
};
var page = document.getElementById('billReport');
this.printer.print(page, options);
}
else{
this.alert('Please connect your device to a printer!');
}
}
else{
this.alert('You are on a web browser!');
}
}
alert(message: string) {
this.alertCtrl.create({
title: 'Info!',
subTitle: message,
buttons: ['OK']
}).present();
}
}
Whenever I click on a print button, nothing happens! 每当我单击打印按钮时,什么都不会发生!
Did anyone have this kind of troubles with the plugin ? 有人在插件方面遇到这种麻烦吗? Did I do something wrong ?
我做错什么了吗 ? Should I install other things to fix the problem ?
我应该安装其他东西来解决问题吗? And did anyone have a exemple project working well ?
有人做过一个很好的项目吗?
Thank you very much ! 非常感谢你 !
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.