科尔多瓦打印机插件不打印

时间:2019-05-19 08:07:34

标签: ios cordova ionic-framework cordova-plugins printers

我正在尝试从我的cordova应用程序中打印html文件。 我已经安装了cordova-plugin-printer。 在app.module.ts文件中导入了插件,之后,当我尝试使用this.printer.print('hello') 注意一点都发生

从'@ ionic-native / printer / ngx'导入{Printer,PrintOptions};

私人打印机:打印机

Print(){
  console.log("Print Pressed");
  var options = {
    font: {
        size: 22,
        italic: true,
        align: 'center'
    },
    header: {
        height: '6cm',
        label: {
            text: "\n\nDie Freuden",
            font: {
                bold: true,
                size: 37,
                align: 'center'
            }
        }
    },
    footer: {
        height: '4cm',
        label: {
            text: 'Johann Wolfgang von Goethe, 1749-1832, deutscher Dichter, Naturforscher',
            font: { align: 'center' }
        }
    }
};

this.printer.print("hello",options);
  console.log("Print Pressed>>>");

}

1 个答案:

答案 0 :(得分:1)

尝试:

Print(){
let options: PrintOptions = {
     name: 'MyDocument',
     printerId: 'printer007',
     duplex: true,
     landscape: true,
     grayscale: true
};
//Checks whether the device is capable of printing
this.printer.isAvailable().then(()=>{
   console.log("printer available")
}).catch((error)=>{
   console.log("printer not available"+error); 
}); 
}