I needed to run JsBarcCode in node, but didn't want to add the complexity of node-canvas and cairo into my build system.
npm install --save jsbarcode jimp jimp-canvas
const JsBarcode = require('jsbarcode')
const Canvas = require('./jimp-canvas')
function routeHandler (req, res) {
let canvas = new Canvas()
JsBarcode(canvas, 'ABC123', {
format: 'CODE128'
})
canvas.getBufferAsPng(function (err, buffer) {
res.type('.png')
res.send(buffer)
})
}
Truly a junk yard implementation of the bare minimum canvas '2d' feature set needed for CODE128 in JsBarCode canvas renderer. The font sized is fixed incorrecrly at 16, the colors are fixed at black and white, etc.