1.1.8 • Published 9 months ago

react-native-savanitdev-thermal-printer v1.1.8

Weekly downloads
-
License
SavanitDev
Repository
github
Last release
9 months ago

react-native-savanitdev-thermal-printer

Support

| Expo | ✅
| React Native CLI | ✅ | Flutter | ✅

ImplementAndroidIOS
Base64
Labelcontactcontact
multiple printcontactcontact
XPrinter
ZyWell

Support

PrinterAndroidIOS
BLEPrinter
NetPrinter
USBcoming soon

Example multiple printing 5 printers

  • video link support print WIFI,BTE and USB in one time

Watch the video on YouTube

Installation

npm i react-native-savanitdev-thermal-printer

or

yarn add react-native-savanitdev-thermal-printer

Example

Print Columns Text

npm i esc-pos-encoder-savanitdev
import EscPosEncoder from "esc-pos-encoder-savanitdev";
import { Buffer } from "buffer";

useEffect(() => {
  if (Platform.OS === "android") {
    onCreate();
  }
}, []);

const printRaw = () => {
  let encoder = new EscPosEncoder();
  let result = encoder
    .table(
      [
        { width: 36, marginRight: 2, align: "left" },
        { width: 10, align: "right" },
      ],
      [
        ["Item 1", "€ 10,00"],
        ["Item 2", "15,00"],
        ["Item 3", "9,95"],
        ["Item 4", "4,75"],
        ["Item 5", "211,05"],
        ["", "=".repeat(10)],
        ["Total", (encoder) => encoder.bold().text("€ 250,75").bold()],
      ]
    )
    .encode();
  const base64string = Buffer.from(result).toString("base64");
  printRawData(base64string, "your ip printer");
};

Print image

const printImg = () => {
  if (Platform.OS === "android") {
    // for IOS if you got error when print image please check your size of your image it's just limit 10-20mb
    printImgNet("192.168.1.xxx", "your image base64string");
  } else {
    // for android
    printImgNet("192.168.1.xxx", "your image base64string", 576, 576);
  }
};

Print Loop different IP printer

// example for IOS
const printLoop = () => {
  for (let i = 0; i < ListIPPrinter.length; i++) {
    const res = ListIPPrinter[i];
    connectNet(res.ip)
      .then((e: any) => {
        printTest(res.ip);
      })
      .catch((err: any) => {
        // do something
      });
  }
};

// example for android
const printLoop = () => {
  for (let i = 0; i < ListIPPrinter.length; i++) {
    const res = ListIPPrinter[i];
    await new Promise((resolve) => {
      connectNet(res.ip_address)
        .then((e) => {
          setTimeout(() => {
            printImgBase64(base64, 576, 576)
              .finally(() => {
                disConnect(res.ip_address);
                setTimeout(resolve, 500);
              })
              .catch((e) => {
                console.log("error print =>", e);
              });
          }, 500);
        })
        .catch((err) => {
          setTimeout(resolve, 0);
        });
    });
  }
};

Support Me by give Star ⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️

FAQ Support 🔰🔰🔰

you can contact me directly Telegram, feedback your problem

or ✉️

Telegram : @dev_la Fanpage : https://www.facebook.com/SavanitDev

Thank you guys

1.1.8

9 months ago

1.1.7

9 months ago

1.1.6

10 months ago

1.1.5

10 months ago

1.1.1

12 months ago

1.1.0

12 months ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.1.4

11 months ago

1.0.5

1 year ago

1.1.3

11 months ago

1.1.2

12 months ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.0

2 years ago