Skip to content

JsBarCode support in node via minimal canvas 2d built on Jimp JS

License

Notifications You must be signed in to change notification settings

sullivanpt/jimp-canvas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A (very) incomplete canvas 2d built on Jimp JS for node

I needed to run JsBarcCode in node, but didn't want to add the complexity of node-canvas and cairo into my build system.

Setup:

npm install --save jsbarcode jimp jimp-canvas

Usage as express route handler:

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)
  })
}

Caveats:

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.

About

JsBarCode support in node via minimal canvas 2d built on Jimp JS

Resources

License

Stars

Watchers

Forks

Packages

No packages published