ESC/POS with XML interface
npm install escpos-xmlJavaScript library that implements the thermal printer ESC / POS protocol and provides an XML interface for preparing templates for printing.
Features:
- [x] Text
- [x] Text line
- [x] Feed line
- [x] Bold text
- [x] Underline text
- [x] Font size
- [x] Small mode
- [x] White mode
- [x] Align
- [x] Barcode
- [x] QRcode
- [ ] Image
- [x] XML with Handlebars
- [x] Handlebars Moment Helper
- [x] Handlebars Numeral Helper
Using npm:
```
npm install --save escpos-xml
In JavaSript:
jsimport { EscPos } from '@datahex/escpos-xml';
const xml =
;const buffer = EscPos.getBufferXML(xml);
// send this buffer to a stream (eg.: bluetooth)
`$3
`jsimport { EscPos } from '@datahex/escpos-xml';
const xml =
;const data = {
foo: 'hello word'
};
const buffer = EscPos.getBufferFromTemplate(xml, data);
// send this buffer to a stream (eg.: bluetooth)
`$3
`jsimport { EscPos } from '@datahex/escpos-xml';
const buffer = EscPos.getBufferBuilder()
.printTextLine('hello world')
.build();
// send this buffer to a stream (eg.: bluetooth)
`API
Comming soon...
For a while, this example may help you:
`js
import { EscPos } from '@datahex/escpos-xml';const xml =
;const data = {
title: 'Tile',
subtitle: 'Subtitle',
description: 'This is a description',
date: new Date(),
price: 1.99,
condictionA: false,
condictionB: true,
barcode: '12345678',
qrcode: 'hello qrcode',
underline: 'underline'
}
const buffer = EscPos.getBufferFromTemplate(xml, data);
// send this buffer to a stream (eg.: bluetooth)
``