JsBarcode is a simple way to create different types of 1d barcodes. It works both in the browser with or without jQuery and also in Node.js
- CODE128
- CODE128 B
- CODE128 C
- EAN 13
- EAN 8
- UPC-A
- CODE39
- ITF
- ITF-14
- MSI
- MSI10
- MSI11
- MSI1010
- MSI1110
- Pharmacode
<img id="barcode">
$("#barcode").JsBarcode("Hi!");
$("#barcode").JsBarcode("9780199532179", {
format:"EAN",
displayValue:true,
fontSize:24,
lineColor: "#0cc"
});
JsBarcode("#barcode","JsBarcode is easy!",{width:1,height:25});
Include the script in your code:
<script src="JsBarcode.all.min.js"></script>
You can also use Bower to install and manage the library.
bower install jsbarcode --save
npm install jsbarcode
npm install canvas
var JsBarcode = require('jsbarcode');
var Canvas = require("canvas");
var canvas = new Canvas();
JsBarcode(canvas, "Hello");
// Do what you want with the canvas
// See https://github.com/Automattic/node-canvas for more information
{
width: 2,
height: 100,
format: "auto",
displayValue: true,
fontOptions: "",
font: "monospace",
textAlign: "center",
textMargin: 2,
fontSize: 14,
background: "#fff",
lineColor: "#000",
margin: 10,
marginTop: undefined,
marginBottom: undefined,
marginLeft: undefined,
marginRight: undefined,
valid: function(valid){}
}