2017-11-11 14 views
0

청구서 보고서 인쇄 옵션을 구현하기 위해 @ ionic-native/printer 플러그인을 사용했습니다. 나는이 명령 줄을 사용하여 플러그인을 설치 한@ ionic-native/printer가 작동하지 않습니다.

: 그럼 내 viewbill.ts 코드

<button ion-button (click)="print()"> 
    <ion-icon name="print"> 
     </ion-icon> 
     Print 
    </button> 

:

를 그런 다음 viewbill.html에 내가 활성에 프린터를 선을 넣어
npm install --save @ionic-native/printer 

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

인쇄 버튼을 클릭 할 때마다 아무런 변화가 없습니다.

누구나 플러그인에 이런 문제가 있습니까? 내가 뭐 잘못 했어요 ? 문제를 해결하기 위해 다른 것을 설치해야합니까? 그리고 누구나 잘 작동하는 예를 들어있는 프로젝트가 있습니까?

대단히 감사합니다!

답변

0

당신은 codrova 플러그인을 설치하는 단계를 놓친 것 같다 :

ionic cordova plugin add de.appplant.cordova.plugin.printer 

이온 기본 패키지는 위의 플러그인에 대한 래퍼입니다. 문서 확인 here

관련 문제