JsBarcode is a simple way to create different types of 1d barcodes.
- EAN (13)
- CODE128 (B)
- Validating the input to see if it can be encoded
- Encode to barcode format (binary output)
var barcode = new EAN("9780199532179");
barcode.valid(); //Result: true
var barcode = new EAN("9780199532179");
barcode.encoded(); //Result: 1010111011000100101001....
####A Html5Canvas barcode generator is included to draw the barcodes.
drawBinary(binaryString, context, options);
####Where:
- binaryString is the string that the barcode encoders generates
- context is a Html5Canvas context
- options is further options, put in a JSON object
####The default options:
{
width:2,
height:100,
x:0,
y:0,
quietZone:10,
}
var barcode = new EAN("9780199532179");
drawBinary(barcode.encoded(), ctx); //If ctx is a defined canvas context
var barcode = new CODE128("Javascript is fun!");
drawBinary(barcode.encoded(), ctx, {width:1,height:20}); //If ctx is a defined canvas context