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 = ; let myPrinter = ; // Optionally pass in the manufacturer & vendor ID(s)let myPrintJob = ; myPrinter; // Optionally specify manufacturer and vendor ID(s) here too myPrintJobtext'hello, printed world!'; // Add some plain text to the output myPrinter; // Send the job to the printer
Usage
const Printer PrintJob = ; let myPrinter = ;let myPrintJob = ; myPrinter; // Make a pretty page...myPrintJob; // add some paddingmyPrintJobtext 'This is line 1' ; // add some text myPrintJob; // change the text alignmentmyPrintJob; // draw a horizontal line myPrintJob;myPrintJobtext 'This is line 2' ; myPrintJob;myPrintJob; myPrintJobtext 'And line 3' ; myPrintJob;myPrintJob; // slice dat. // Send the printJob to the printermyPrinter;
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