giorgiofellipe / cordova-plugin-datecs-printer

Cordova plugin to print on Mobile Bluetooth ESC/POS Printers - Tested on Datecs DPP-250 Printer
MIT License
73 stars 60 forks source link

printText() method not working #160

Open alexsusin opened 3 years ago

alexsusin commented 3 years ago

I have a Datecs DPP-350 printer with which I can't print text unless I put an image or a QR to print as well. Also, it only works randomly, I can't get it to always print what I want. It would also help me to know how to use the setPageRegion method. With this code everything explained above happens:

  window.DatecsPrinter.listBluetoothDevices(
    function (devices) {
      window.DatecsPrinter.connect(devices[0].address,
        function () {
          printSomeTestText();
        },
        function () {
          alert(JSON.stringify(error));
        }
      );
    },
    function (error) {
      alert(JSON.stringify(error));
    }
  );

  function printSomeTestText() {
    window.DatecsPrinter.printText("Demo", 'ISO-8859-1',
      function () {
        printQRCode();
      }
    );
  }

  function printQRCode() {
    window.DatecsPrinter.printQRCode(
      4,
      4,
      'http://giorgiofellipe.com.br',
      function () {
        alert('success!');
        window.DatecsPrinter.disconnect();
      },
      function () {
        alert(JSON.stringify(error));
      }
    );
  }