Skip to content
المشاريع

tr3v3r/react-native-esc-pos-printer

عرض على GitHub

حول

🖨️ مكتبة React Native غير رسمية للطباعة باستخدام طابعة EPSON TM عبر Epson ePOS SDK لنظام iOS وEpson ePOS SDK لنظام Android

تطوير الويب والتطبيقات

كيف تُقاس هذه الأرقام

ما يمكنك فعله

  • Supports BLE, LAN, USB and Wi-Fi connection methods
  • Print receipts natively and from React Native views
  • Compatible with the new architecture
  • Build-in queue mechanism

النمو المقاس للنجوم

خلال 24 ساعة
٠
خلال 7 أيام
٠
خلال 15 يومًا
٠
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

Printer

npm version

Features

  • Supports BLE, LAN, USB and Wi-Fi connection methods
  • Print receipts natively and from React Native views
  • Compatible with the new architecture
  • Build-in queue mechanism
  • Clear errors descriptions
  • Proxy-like API makes it easy to add new commands

Installation

React Native

[!WARNING]
For react-native lower than 0.76.x version, use react-native-esc-pos-printer 4.3.3 or lower

yarn add react-native-esc-pos-printer

Expo

npx expo install react-native-esc-pos-printer
npx expo prebuild

Also complete this required steps

Usage

Discover printers

import { usePrintersDiscovery } from 'react-native-esc-pos-printer';

function App() {
  const { start, isDiscovering, printers } =
    usePrintersDiscovery();

    useEffect(() => {
      start();
    }, []);
}

Print

import { Printer } from 'react-native-esc-pos-printer';

function App() {
  const { start, isDiscovering, printers } =
    usePrintersDiscovery();

    useEffect(() => {
      start();
    }, []);

    const print = () => {
      // printing on all discovered printers
      printers.forEach(printersData => {
          const printerInstance = new Printer({
            target: printersData.target,
            deviceName: printersData.deviceName,
          });

          const res = await printerInstance.addQueueTask(async () => {
            await Printer.tryToConnectUntil(
              printerInstance,
              (status) => status.online.statusCode === PrinterConstants.TRUE
            );
            await printerInstance.addText('DUDE!');
            await printerInstance.addFeedLine();
            await printerInstance.addCut();
            const result = await printerInstance.sendData();
            await printerInstance.disconnect();
            return result;
        })
      })
  }

  return <Button title="Print" onPress={print} />;
}

Documentation

https://tr3v3r.github.io/react-native-esc-pos-printer

Sponsor this project

If you like what I'm doing and want to support me, you can:

Buy me a coffee

Known issues

  1. It's not possible to print and discover on Android simulator.

  2. If you have an issue with using Flipper on iOS real device, try this workaround.

License

MIT

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…