Skip to content
Projetos

tr3v3r/react-native-esc-pos-printer

Ver no GitHub

Sobre

🖨️ Biblioteca não oficial de React Native para imprimir em uma impressora EPSON TM usando o Epson ePOS SDK para iOS e o Epson ePOS SDK para Android

Desenvolvimento web e de aplicativos

Como estes números são medidos

O que você pode fazer

  • 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

Crescimento medido de estrelas

em 24 h
0
em 7 dias
0
em 15 dias
0
em 1 mês
Coletando histórico

Variações líquidas em períodos sobrepostos, não totais diários. Medições ausentes ficam em branco. Estrelas indicam interesse, não qualidade.

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 projetos relacionados

Carregando…