react-native-savanitdev-thermal-printer

1.1.8 • Public • Published

react-native-savanitdev-thermal-printer

Support

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

Implement Android IOS
Base64
Label contact contact
multiple print contact contact
XPrinter
ZyWell

Support

Printer Android IOS
BLEPrinter
NetPrinter
USB coming soon

bill screenshot

Example multiple printing 5 printers

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

Watch the video on YouTube

<iframe width="560" height="315" src="https://www.youtube.com/embed/hyEmWCuuu-g" title="Thermal printer ESC POS multiple printing by Savanitdev library" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>

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 ⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️

Star the SavanitDev repo on GitHub to support the project

FAQ Support 🔰🔰🔰

you can contact me directly Telegram, feedback your problem

or ✉️

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

Thank you guys

Readme

Keywords

none

Package Sidebar

Install

npm i react-native-savanitdev-thermal-printer

Weekly Downloads

5

Version

1.1.8

License

SavanitDev

Unpacked Size

8.21 MB

Total Files

486

Last publish

Collaborators

  • savanitdev