Formally known as EscPosEncoder, StarPrntEncoder and ThermalPrinterEncoder
Create a set of commands that can be send to any receipt printer that supports ESC/POS, StarLine or StarPRNT.
- About ReceiptPrinterEncoder
- Usage and installation
- Configuration options
- Handling text
- Commands for creating receipts
- Printing receipts
- Migrating from version 2 to version 3
This package is compatible with browsers and Node. It provides bundled versions for direct use in the browser and can also be used as an input for your own bundler. And of course there are ES6 modules and CommonJS versions for use in Node and Deno.
The dist
folder contains bundles that can be directly used in the browser. We both have a modern ES6 module, or a legacy UMD bundle.
Import ReceiptPrinterEncoder
from the receipt-printer-encoder.esm.js
file located in the dist
folder.
import ReceiptPrinterEncoder from 'receipt-printer-encoder.esm.js';
let encoder = new ReceiptPrinterEncoder();
let result = encoder
.initialize()
.text('The quick brown fox jumps over the lazy dog')
.newline()
.qrcode('https://nielsleenheer.com')
.encode();
Alternatively you can load the receipt-printer-encoder.umd.js
file located in the dist
folder and instantiate a ReceiptPrinterEncoder
object.
<script src='dist/receipt-printer-encoder.umd.js'></script>
<script>
let encoder = new ReceiptPrinterEncoder();
</script>
Or if you prefer a loader like RequireJS, you could use this:
requirejs([ 'dist/receipt-printer-encoder.umd' ], ReceiptPrinterEncoder => {
let encoder = new ReceiptPrinterEncoder();
});
If you want to use this libary, first install the package using npm:
npm install @point-of-sale/receipt-printer-encoder --save
If you prefer ES6 modules, then import ReceiptPrinterEncoder
from @point-of-sale/receipt-printer-encoder
and use it like so:
import ReceiptPrinterEncoder from '@point-of-sale/receipt-printer-encoder';
let encoder = new ReceiptPrinterEncoder();
let result = encoder
.initialize()
.text('The quick brown fox jumps over the lazy dog')
.newline()
.qrcode('https://nielsleenheer.com')
.encode();
Alternatively you could use the CommonJS way of doing things and require the package:
let ReceiptPrinterEncoder = require('@point-of-sale/receipt-printer-encoder');
let encoder = new ReceiptPrinterEncoder();
This library does not have a dedicated package on deno.land/x
, but you can directly import the NPM package. It is fully compatible with Deno.
import ReceiptPrinterEncoder from 'npm:@point-of-sale/receipt-printer-encoder';
let encoder = new ReceiptPrinterEncoder();