tiny-esc-pos

0.1.7 • Public • Published

tiny-esc-pos

A Node.js helper package for using ESC/POS printer.

Usage

Using npm

# Install tiny-esc-pos 
npm i tiny-esc-pos --save

Then you can import

import TinyPOS from 'tiny-esc-pos';

Example

// This package was mainly created for bluetooth ESC/POS printers
import BluetoothSerial from 'react-native-bluetooth-serial';
import TinyPOS from 'tiny-esc-pos';
 
// Make sure you are already connected to the printer
const writePromises = [];
 
// Reset printer format
writePromises.push(BluetoothSerial.write(TinyPOS.init()));
 
// Write 'Hello World' with new line
writePromises.push(BluetoothSerial.write(
    TinyPOS.bufferedText('Hello World', {
        size: 'doubleheight',
        align: 'center',
        weight: 'bold'
    }, true) // new line
));
 
// Previously passed config will also take effectt
writePromises.push(BluetoothSerial.write(
    TinyPOS.bufferedText('Simple Receipt Test', {
        size: 'normal',
    })
));
 
// Add 3 new lines
writePromises.push(BluetoothSerial.write(
    TinyPOS.bufferedLine(3)
));
 
writePromises.push(BluetoothSerial.write(
    TinyPOS.bufferedText('Sample Receipt')
))
 
// Offset printing (our test printer won't feed until the end of the printing)
writePromises.push(BluetoothSerial.write(
    TinyPOS.print(2)
));
 
Promise.all(writePromises)
.then(res => console.log(res))
.catch(err => console.log(err.message));

Package Sidebar

Install

npm i tiny-esc-pos

Weekly Downloads

2

Version

0.1.7

License

ISC

Unpacked Size

7.93 kB

Total Files

4

Last publish

Collaborators

  • irayspace