npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@happy-gastro/react-native-printer-module

v1.5.11

Published

Native bridge for ESC/POS thermal printers (Bluetooth and TCP / IP)

Readme

React Native Printer BL and IP printer module

react-native-notification-badge GitHub követők

Native bridge for thermal printer, forked from react-native-thermal-printer with additional features.

Description

This module provides a bridge for printing on thermal printers using React Native. It supports both network and Bluetooth printing. We must added some editing into Java files to work well with Bluetooth and Hungarian characters and we will add some other features soon.

Android Only (Working on iOS)

This module bridges the following library: https://github.com/DantSu/ESCPOS-ThermalPrinter-Android/tree/3.0.1

Installation

npm @happy-gastro/install react-native-printer-module

or

yarn add @happy-gastro/react-native-printer-module

Android Manifest Configuration

Ensure the following permissions are added to android/app/src/main/AndroidManifest.xml:

For network printing:

<uses-permission android:name="android.permission.INTERNET"/>

For Bluetooth printing:

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

Usage

Import the Module

import PrinterModule from 'react-native-printer-module';

Set Default Configuration

PrinterModule.defaultConfig.ip = '192.168.100.246';
PrinterModule.defaultConfig.port = 9100;
PrinterModule.defaultConfig.autoCut = false;
PrinterModule.defaultConfig.timeout = 30000; // in milliseconds

or

PrinterModule.defaultConfig = {
  ...PrinterModule.defaultConfig,
  ip: '192.168.100.246',
  port: 9100,
  autoCut: false,
  timeout: 30000, // in milliseconds
};

Sending a Print Job

// Inside an async function
try {
  await PrinterModule.printTcp({ payload: 'Hello, world!' });
} catch (err) {
  console.log(err.message);
}

You can also specify the configuration for each call:

// Inside an async function
try {
  await PrinterModule.printTcp({
    ip: '192.168.100.246',
    port: 9100,
    payload: 'Hello, world!',
    printerWidthMM: 50,
    timeout: 30000,
  });

  await PrinterModule.printTcp({
    ip: '192.168.100.247',
    port: 9100,
    payload: 'Hello, world!',
    autoCut: false,
    timeout: 30000,
  });
} catch (err) {
  console.log(err.message);
}

Bluetooth Printing

Pair your Bluetooth device and use the printBluetooth method. The configurations remain the same.

// Inside an async function
try {
  await PrinterModule.printBluetooth({
    payload: 'Hello, world!',
    printerNbrCharactersPerLine: 38,
  });
} catch (err) {
  console.log(err.message);
}

Methods

Supports both network and Bluetooth printing.

| Method | Parameter | Parameter Type | Default | | -------------- | --------- | ---------------------------------------------------------------------- | --------------- | | printTcp | config | Partial<PrintTcpInterface> & Pick<PrinterInterface, 'payload'> | defaultConfig | | printBluetooth | config | Partial<PrintBluetoothInterface> & Pick<PrinterInterface, 'payload'> | defaultConfig |

Interfaces and Configurations

// Default parameters
function PrinterInterface(payload, autoCut, openCashbox, mmFeedPaper, printerDpi, printerWidthMM, printerNbrCharactersPerLine) {
  this.payload = payload;
  this.autoCut = autoCut;
  this.openCashbox = openCashbox;
  this.mmFeedPaper = mmFeedPaper;
  this.printerDpi = printerDpi;
  this.printerWidthMM = printerWidthMM;
  this.printerNbrCharactersPerLine = printerNbrCharactersPerLine;
}

// Printing on TCP / IP printers
function PrintTcpInterface(ip, port, timeout, payload, autoCut, openCashbox, mmFeedPaper, printerDpi, printerWidthMM, printerNbrCharactersPerLine) {
  PrinterInterface.call(this, payload, autoCut, openCashbox, mmFeedPaper, printerDpi, printerWidthMM, printerNbrCharactersPerLine);
  this.ip = ip;
  this.port = port;
  this.timeout = timeout;
}

// Printing to Bluetooth printers
function PrintBluetoothInterface(macAddress, payload, autoCut, openCashbox, mmFeedPaper, printerDpi, printerWidthMM, printerNbrCharactersPerLine) {
  PrinterInterface.call(this, payload, autoCut, openCashbox, mmFeedPaper, printerDpi, printerWidthMM, printerNbrCharactersPerLine);
  this.macAddress = macAddress;
}

Default Configuration

const defaultConfig = {
  ip: '192.168.1.121',
  port: 9100,
  payload: '',
  autoCut: true,
  openCashbox: false,
  mmFeedPaper: 20,
  printerDpi: 203,
  printerWidthMM: 80,
  printerNbrCharactersPerLine: 42,
  timeout: 30000,
};

Available Config Options

| Name | Type | Default | Description | | --------------------------- | --------- |-----------------| -------------------------------- | | ip | string | 192.168.1.121 | Printer IP address | | port | number | 9100 | Printer port | | payload | string | `` | Text sent to the printer | | autoCut | boolean | true | Automatically cut the paper | | openCashbox | boolean | false | Open cashbox after printing | | mmFeedPaper | number | 20 | Paper feed in millimeters | | printerDpi | number | 203 | Printer DPI | | printerWidthMM | number | 80 | Printing width in millimeters | | printerNbrCharactersPerLine | number | 42 | Maximum characters per line | | timeout | number | 30000 | Timeout duration in milliseconds |

Example

const text =
  '[C]<img>https://via.placeholder.com/300.jpg</img>\n' +
  '[L]\n' +
  "[C]<u><font size='big'>ORDER #316-235</font></u>\n" +
  '[L]\n' +
  '[C]================================\n' +
  '[L]\n' +
  '[L]<b>PRODUCT NAME</b>[R]9.99€\n' +
  '[C]--------------------------------\n' +
  '[R]TOTAL PRICE :[R]34.98€\n' +
  '[R]TAX :[R]4.23€\n' +
  '[C]================================\n' +
  '[C]Thank You for beeing Our customer:\n' +
  '[C]Happy Solutions\n' +
  '[C]www.happysolutions.hu\n\n' +
  '[C]<barcode type="ean13" height="10">831254784551</barcode>\n' +
  '[C]<qrcode size="20">http://example.com/</qrcode>\n';

Tested Devices

  • Epson Printers
  • Bixolon Printers
  • SunMe Devices inner printers
  • iMin Devices inner printers
  • No-name Bluetooth printers
  • Zywell
  • VSC
  • EPPOS

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Author

This project is maintained by Farkas Ferenc.

Company

Happy Gastro Ltd.

License

MIT