node-excelvan
v0.2.3
Published
A nodejs library to manipulate ExcelVan ESC/POS printers.
Downloads
10
Maintainers
Readme
node-excelvan
A nodejs library to interact with the Excelvan (and possibly other) escpos printer over usb.
Getting started
Install dependencies:
- Windows: Install Zagig then install a driver for the printer
- Linux: Run
sudo apt-get install libudev-dev
Install the module npm install --save node-excelvan
Plug in the printer.
const { Printer, PrintJob } = require( 'node-excelvan' );
let myPrinter = new Printer(); // Optionally pass in the manufacturer & vendor ID(s)
let myPrintJob = new PrintJob();
myPrinter.connect(); // Optionally specify manufacturer and vendor ID(s) here too
myPrintJob.text('hello, printed world!'); // Add some plain text to the output
myPrinter.print(myPrintJob); // Send the job to the printer
Usage
const { Printer, PrintJob } = require( 'node-excelvan' );
let myPrinter = new Printer();
let myPrintJob = new PrintJob();
myPrinter.connect();
// Make a pretty page...
myPrintJob.pad( 1 ); // add some padding
myPrintJob.text( 'This is line 1' ); // add some text
myPrintJob.setTextAlignment( 'center' ); // change the text alignment
myPrintJob.separator(); // draw a horizontal line
myPrintJob.setTextAlignment( 'right' );
myPrintJob.text( 'This is line 2' );
myPrintJob.setTextAlignment( 'center' );
myPrintJob.separator();
myPrintJob.text( 'And line 3' );
myPrintJob.pad( 1 );
myPrintJob.cut(); // slice dat.
// Send the printJob to the printer
myPrinter.print( myPrintJob, function () {
console.log( "It's finished printing!!" );
} );
PrintJob
text
param: text { String } The text to print
adds plain text to the output
newLine
param: count { Number } How many new lines to print
prints a newline character
pad
param: count { Number } How much white-space (in vertical units)
adds vertical white-space
setTextFormat
param: format { String } The format to set
(coming soon) set various aspects of font
setFont
param: font { String } The font to use. Either 'A' or 'B'
choose font A or font B
setBold#
param: enabled { Boolean } Whether to turn bold on or off
set bold to true/false
setUnderline
param: enabled { Boolean } Whether to turn underline on or off
set underline to true/false
setTextAlignment
param: alignment { String } What to set the text alignment to
sets text alignment to 'left', 'center' or 'right'
separator
print horizontal line
cut
cuts paper
Printer
connect
param: manufacturerId { String } The usb device's manufacturer ID
param: vendorId { String } The usb device's vendor ID
param: callback { Function } called on completion
establishes a connection to the printer, taking control from the OS
disconnect
param: callback { Function } called on completion
returns control of the printer to the OS and closes the connection to it
param: printJob { Object:PrintJob } The job to print
param: callback { Function } called on completion
sends the commands in the printJob
License
MIT
Thanks
The python-escpos team - for creating the original, Python version
@StaduimRunner - for their great work creating a nodejs version