HeligPfleigh / react-native-thermal-receipt-printer

A RN library for thermal printer
155 stars 102 forks source link

2 is coming in first line #169

Open bhargavpmistri opened 5 months ago

bhargavpmistri commented 5 months ago

Current Behavior

vozaldi commented 3 months ago

Screenshot_42

I'm using master branch and it has "2" text on every print session with BLEPrinter.printText(text) method.

arnoldochavez commented 2 months ago

Same problem, have you guys found a solution?

thecodecafe commented 2 months ago

@arnoldochavez @bhargavpmistri @vozaldi Add a manual delay on your end after each print command.

function Sleep(ms: number) {
   return new Promise((res) => {
      setTimeout(ms, () => {
        res()
      )
   });
}

With the above code you can do the following

...
printLineOne()
await Sleep(50)
printLineTwo()
await Sleep(50)
printLineThree()
Sleep(50)
...

With the above, all of the items you print will be printed in the correct sequence.

arnoldochavez commented 2 months ago

@thecodecafe there isn't a problem with the sequence of the printing, the problem is that a 2 appears when printing

jltrench commented 1 month ago

Same bug here, i solved using the encoding option, ex:

const printTextTest = () => {
    currentPrinter &&
      BLEPrinter.printText('<C>Testing...</C>\n', {
        encoding: 'UTF-8', // -> Add this line
      });
  };
vozaldi commented 1 month ago
const printTextTest = () => {
    currentPrinter &&
      BLEPrinter.printText('<C>Testing...</C>\n', {
        encoding: 'UTF-8', // -> Add this line
      });
  };

I tested this config and it works for my BLE printer. Thanks @jltrench