-1

I m trying to print a html file from my cordova app. I have installed the cordova-plugin-printer. In app.module.ts file imported the plugin and after that when i try to use this.printer.print('hello') Noting happens at all

import { Printer, PrintOptions } from '@ionic-native/printer/ngx';

private printer: Printer

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>>>");

}
puja
  • 87
  • 11

1 Answers1

1

Try:

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); 
}); 
}
Khurshid Ansari
  • 4,638
  • 2
  • 33
  • 52