Skip to content
프로젝트

tr3v3r/react-native-esc-pos-printer

GitHub에서 보기

소개

🖨️ iOS용 및 Android용 Epson ePOS SDK를 사용해 EPSON TM 프린터로 인쇄하는 비공식 React Native 라이브러리

웹 및 앱 개발

이 수치를 측정하는 방법

What you can do

  • 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

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

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

관련 프로젝트 살펴보기

불러오는 중…