Need private packages and team management tools?Check out npm Teams »

node-excelvan

0.2.3 • Public • Published

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

print

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

Install

npm i node-excelvan

DownloadsWeekly Downloads

0

Version

0.2.3

License

MIT

Last publish

Collaborators

  • avatar