【问题标题】:cordova printer plugin is not printing t科尔多瓦打印机插件不打印
【发布时间】:2019-05-19 08:07:34
【问题描述】:

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

从'@ionic-native/printer/ngx'导入{打印机,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>>>");

}

【问题讨论】:

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


    【解决方案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); 
    }); 
    }
    

    【讨论】:

    • 代码没有被执行,既不会成功也不会失败。我在 Print() 之后写了一个控制台日志,只是在控制台中打印。
    • 表示打印机不可用
    • 没有连接打印机,我正在尝试模拟器,但至少应该显示打印预览页面
    • 哦,所以你想看预览。
    • 什么都没有,我也看不到预览也看不到任何控制台语句,现在我在ios模拟器上运行代码并且没有任何连接的打印机
    猜你喜欢
    • 1970-01-01
    • 2017-01-27
    • 2015-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-30
    • 1970-01-01
    • 2015-05-19
    相关资源
    最近更新 更多