Skip to content
Projects

tr3v3r/react-native-esc-pos-printer

View on GitHub

About

🖨️ An unofficial React Native library for printing on an EPSON TM printer with the Epson ePOS SDK for iOS and Epson ePOS SDK for Android

Web & App Development

How these counts are measured

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

Measured star growth

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

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

Explore related projects

Loading…