alfonsovinti / cordova-plugin-bixolon-print

8 stars 17 forks source link

How to use it on ionic3 ? #22

Open uokivan opened 5 years ago

uokivan commented 5 years ago

Can anyone tell me that how to use it on ionic3, please

feroz04 commented 5 years ago

first add this plugin: cordova plugin add cordova-plugin-bixolon-printer

run this method after connect the printer into ur device :

declare var cordova:any;

  print(){

  cordova.plugins.bixolonPrint.getStatus(
 function (resp) {
  cordova.plugins.bixolonPrint.addLine({
    text: "This is a test print",
    textAlign: cordova.plugins.bixolonPrint.TextAlign.CENTER
  });

  cordova.plugins.bixolonPrint.printText(
    function (response) {
      console.log("print success!");
    },
    function (error) {
      console.log("print failure: " + error.message);
    }
  );
},
function (err) {
  console.log("Error in printer : " + err.message);
  let alert = this.alertCtrl.create({
    title: "ERROR " + err,
    buttons: ['Dismiss']
  });
  alert.present();
}, true);

}