How to print to termal receipt printer

Hi,

I am not a developer but our team is asking for more information how to be able to connect termal printers in the application. We want to be able to print to termal receipt pos printer. (Can be bluetooth or wifi) Anything would be great.

Can anyone help us?

Regards.

do you get any solution?

How to integrate Bluetooth with IONIC 3 ?

//home.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { BluetoothSerial } from '@ionic-native/bluetooth-serial';
import { AlertController } from 'ionic-angular';

import { BarcodeScanner } from '@ionic-native/barcode-scanner';
import QRCode from 'qrcode';
 
import { Buffer } from 'buffer';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  metin;
  unpairedDevices: any;
  pairedDevices: any;
  gettingDevices: Boolean;
  constructor(private bluetoothSerial: BluetoothSerial,
    private alertCtrl: AlertController,
    private barkodScanner: BarcodeScanner ) {
    bluetoothSerial.enable();
  }

  startScanning() {
    this.pairedDevices = null;
    this.unpairedDevices = null;
    this.gettingDevices = true;
    this.bluetoothSerial.discoverUnpaired().then((success) => {
      this.unpairedDevices = success;
      this.gettingDevices = false;
      success.forEach(element => {
        // alert(element.name);
      });
    },
      (err) => {
        console.log(err);
      })

    this.bluetoothSerial.list().then((success) => {
      this.pairedDevices = success;
    },
      (err) => {

      })
  }
  success = (data) => alert(data);
  fail = (error) => alert(error);

  selectDevice(address: any) {

    let alert = this.alertCtrl.create({
      title: 'Connect',
      message: 'Do you want to connect with?',
      buttons: [
        {
          text: 'Cancel',
          role: 'cancel',
          handler: () => {
            console.log('Cancel clicked');
          }
        },
        {
          text: 'Connect',
          handler: () => {
            this.bluetoothSerial.connect(address).subscribe(this.success, this.fail);
            // this.bluetoothSerial.connect(address).subscribe(data => {
            //   this.yazdir()
            // });

          }
        }
      ]
    });
    alert.present();


  }

  disconnect() {
    let alert = this.alertCtrl.create({
      title: 'Disconnect?',
      message: 'Do you want to Disconnect?',
      buttons: [
        {
          text: 'Cancel',
          role: 'cancel',
          handler: () => {
            console.log('Cancel clicked');
          }
        },
        {
          text: 'Disconnect',
          handler: () => {
            this.bluetoothSerial.disconnect();
          }
        }
      ]
    });
    alert.present();
  }

  yazdir() {
 
    let dataX = "aaaa";
    this.bluetoothSerial.write(this.metin).then(data => {
      console.log(data);
    });


  }
 
}
//home.html
<ion-list padding>
    <button ion-button block (click)="startScanning()">scan</button>
    <ion-list-header>
        Paired Devices
    </ion-list-header>
    <ion-item *ngFor="let device of pairedDevices">
        {{device.name}}
    </ion-item>
    <button ion-button block (click)="disconnect()">Disconnect</button>
    <ion-list-header>
        availlable Devices
    </ion-list-header>
    <ion-item *ngFor='let device of unpairedDevices'>
        <span (click)="selectDevice(device.address)">
      {{device.name}}
    </span>
    </ion-item>
    <ion-spinner name="crescent" *ngIf="gettingDevices"></ion-spinner>
    <ion-input placeholder="Metin" [(ngModel)]="metin"></ion-input>

    <button ion-button block (click)="yazdir()">Yazdır</button>
</ion-list>

@mustafabekec @richardshergold Thank you very much . working good. Can you please tell me how to send a image to bluetoothSerial.write to print a logo image?

@sedar I tried to print the picture but I could not.
I read that the writing method accepts Base64. I sent the Base64 code of any image, but it did not happen again. If you find a solution to please me tagged. I would like to know.

@mustafabekec I am trying to follow this link . Here they have printed logo on blutooth printer. But this is cordova plugin and i am not getting idea how we use this plugin in ionic 2. Please check if you can get any idea so it will help us out.

hi , did you found solution for wifi printer

Hi, did you find the solution ?