Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xseignard/thermalprinter
Use node.js to communicate with Adafruit/Sparkfun Thermal Printer
https://github.com/xseignard/thermalprinter
Last synced: 8 days ago
JSON representation
Use node.js to communicate with Adafruit/Sparkfun Thermal Printer
- Host: GitHub
- URL: https://github.com/xseignard/thermalprinter
- Owner: xseignard
- Created: 2014-05-21T03:26:32.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-10-11T15:54:56.000Z (over 1 year ago)
- Last Synced: 2024-12-27T08:08:28.059Z (15 days ago)
- Language: JavaScript
- Homepage:
- Size: 3.1 MB
- Stars: 105
- Watchers: 8
- Forks: 33
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Control the Adafruit/Sparkfun thermal printer from node.js
[![npm](https://img.shields.io/npm/v/thermalprinter.svg?style=flat-square)](https://www.npmjs.com/package/thermalprinter) [![Travis](https://img.shields.io/travis/xseignard/thermalPrinter.svg?style=flat-square)](https://travis-ci.org/xseignard/thermalPrinter) [![Code Climate](https://img.shields.io/codeclimate/coverage/github/xseignard/thermalPrinter.svg?style=flat-square)](https://codeclimate.com/github/xseignard/thermalPrinter/coverage)
Largely inspired by http://electronicfields.wordpress.com/2011/09/29/thermal-printer-dot-net/
You can print images, but they need to be 384px wide.
It's a fluent API, so you can chain functions, but don't forget to call `print` at the end to actually print something!
## Crappy schematics
You'll need an USB/Serial converter.
![schematics](/images/schema.png)
## Usage
- install with `npm install thermalprinter --save`
- check the demo sample:```js
var SerialPort = require('serialport'),
serialPort = new SerialPort('/dev/ttyUSB0', {
baudRate: 19200
}),
Printer = require('thermalprinter');var path = __dirname + '/images/nodebot.png';
serialPort.on('open',function() {
var printer = new Printer(serialPort);
printer.on('ready', function() {
printer
.indent(10)
.horizontalLine(16)
.bold(true)
.indent(10)
.printLine('first line')
.bold(false)
.inverse(true)
.big(true)
.right()
.printLine('second line')
.printImage(path)
.print(function() {
console.log('done');
process.exit();
});
});
});
```## Demo
![demo](/images/demo.gif)