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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hendrysetiadi/react-native-sunmi-printer

v0.2.0

Published

React Native Library for SUNMI Inner Printer

Readme

react-native-sunmi-printer

React Native Library for SUNMI Inner Printer (Android only)

Installation

npm install @hendrysetiadi/react-native-sunmi-printer

Usage

import SunmiPrinter from '@hendrysetiadi/react-native-sunmi-printer';

// or ES6+ destructured imports

import { initPrinter } from '@hendrysetiadi/react-native-sunmi-printer';

API

getPrinterSerialNo()

getPrinterSerialNo(): Promise<string>

Examples

const serialNo = await SunmiPrinter.getPrinterSerialNo();

getPrinterModel()

getPrinterModel(): Promise<string>

Examples

const printerModel = await SunmiPrinter.getPrinterModel();

getPrinterVersion()

getPrinterVersion(): Promise<string>

Examples

const printerVersion = await SunmiPrinter.getPrinterVersion();

getPrinterPaper()

getPrinterPaper(): Promise<string>

Examples

const printerPaper = await SunmiPrinter.getPrinterPaper();

initPrinter()

initPrinter(): Promise<null>

Initialize printer and reset printer state (font size, alignment, etc.), should be called first before the print call

Examples

await SunmiPrinter.getPrinterPaper();

printLineWrap()

printLineWrap(n: number) : Promise<null>

Print Paper Feed after finishing the Previous printing content

Parameters

  • n : Number of Lines

Examples

await SunmiPrinter.printLineWrap(3);

feedPaper()

feedPaper() : Promise<null>

Feed the paper automatically according to the distance between the paper hatch and the print head. If the device does not support, then replaced by printing three lines

Examples

await SunmiPrinter.feedPaper();

setAlignment()

setAlignment(alignment: number) : Promise<null>

Set the Printing Alignment (Setting the printing alignment will affect subsequent printing unless it is initialized)

Parameters

  • alignment : Alignment Mode (0 = Left, 1 = Center, 2 = Right)

Examples

// Set Alignment to Center
await SunmiPrinter.setAlignment(1);

setFontSize()

setFontSize(fontSize: number) : Promise<null>

Set the Printing Font Size (Setting the font size will affect subsequent printing unless it is initialized). Adjusting the font size will affect the character width and the number of characters per line

Examples

await SunmiPrinter.setFontSize(32);

printText()

printText(content: string) : Promise<null>

Parameters

  • content : Text to Print

Examples

await SunmiPrinter.printText('Hello World');

printTextWithOption()

printTextWithOption(content: string, fontSize: number, isBold: boolean, isUnderline: boolean) : Promise<null>

Print Text with Size, Bold, and Underline options

Parameters

  • content : Text to Print
  • fontSize
  • isBold
  • isUnderline

Examples

await SunmiPrinter.printTextWithOption('Hello World', 24, true, true);

printTextTable()

printTextTable(contentArray: string[], widthArray: number[], alignmentArray: number[]) : Promise<null>

Print Text in a form of Table (can specify the column Width and Alignment)

Parameters

  • contentArray : Array of Text for each Column
  • widthArray : Array of Width ratio for each Column
  • alignmentArray : Array of Alignment for each Column (0 = Left, 1 = Center, 2 = Right)

Examples

await SunmiPrinter.printTextTable(
  ['Date', 'Jan 1st, 10:00 AM'],
  [1, 1],
  [0, 2]
);

printBarcode()

printBarcode(data: string, symbology: number, height: number, width: number, textPosition: number) : Promise<null>

Print One-Dimensional Barcode

Parameters

  • data : Barcode data
  • symbology : Barcode Type
    • 0 = UPC-A
    • 1 = UPC-E
    • 2 = JAN13(EAN13)
    • 3 = JAN8(EAN8)
    • 4 = CODE39
    • 5 = ITF
    • 6 = CODABAR
    • 7 = CODE93
    • 8 = CODE128
  • height : Barcode Height (1 - 255)
  • width : Barcode Width (2 - 6)
  • textPosition : Barcode Text Position
    • 0 = No Text
    • 1 = Text above the Barcode
    • 2 = Text below the Barcode
    • 3 = Text both above and below the Barcode

Examples

await SunmiPrinter.printBarcode('01234567890', 8, 80, 2, 0);

printQrCode()

printQrCode(data: string, moduleSize: number, errorLevel: number) : Promise<null>

Print QR Code (Two-Dimensional Barcode)

Parameters

  • data : QR Code content data
  • moduleSize : QR Code block size in Point (1 - 16)
  • errorLevel : QR Code error correction Level (0 - 3)
    • 0 = Error correction level L (7%)
    • 1 = Error correction level M (15%)
    • 2 = Error correction level Q (25%)
    • 3 = Error correction level H (30%)

Examples

await SunmiPrinter.printQrCode('https://google.com', 8, 2);

printBitmap()

printBitmap(data: string, width: number, height: number) : Promise<null>

Print Bitmap from Base-64 data

Parameters

  • data : Base-64 bitmap data (Maximum width of 384 pixels)
  • width
  • height

Examples

const base64Image = '/9j/2wCEAAEBAQEBAQEBA...BKJzETKAj2KAAH//2Q==';
await SunmiPrinter.printBitmap(base64Image, 320, 80);

Notes

If you want to print local image from device storage, you can use library like rn-fetch-blob or react-native-fs to convert the image to base64


openCashBox()

openCashBox() : Promise<null>

Open the Cash Box. If there is no Cash Box Interface (such as V1, P1) or the call fails, an exception will be thrown

Examples

await SunmiPrinter.openCashBox();

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library