kmshi / JsBarcode

Create different type of barcodes with javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Introduction

JsBarcode is a simple way to create different types of 1d barcodes.
The plugin uses Html5Canvas to generate draw the barcodes

This is the list of supported barcodes:

  • CODE128 (B or C)
  • EAN (13)
  • UPC-A
  • CODE39
  • ITF (Interleaved 2 of 5)
  • ITF14

Use

####There are two ways of using the library: With jQuery:

$(object).JsBarcode(string,options);

Or pure JavaScript:

JsBarcode(object, string, options);

####The parameters:

  • string is the sring to be encoded to the barcode
  • options is additional options put i an object (look below)

####The default options:

{
	width:	2,
	height:	100,
	quite: 10,
	format:	"CODE128",
	displayValue: false,
	font:"Monospaced",
	textAlign:"center",
	fontSize: 12,
	backgroundColor:"",
	lineColor:"#000"
}

Examples

####First we need an image

<img id="barcode">

This code:

$("#barcode").JsBarcode("Hi!");

Will generate this image:

Result

This code:

$("#barcode").JsBarcode("Javascript is fun!",{width:1,height:25});

Will generate this image:

Result

This code:

$("#barcode").JsBarcode("9780199532179",{format:"EAN",displayValue:true,fontSize:20});

Will generate this image:

Result

This code:

setInterval(function(){
	var date = new Date();
	$("#barcode").JsBarcode(date.getHours()+":"+date.getMinutes()+":"+date.getSeconds());
},1000);

Will create a barcode clock:

Click here to see it

Minify the latest code

Use the closure compiler with this input

// ==ClosureCompiler==
// @output_file_name JsBarcode.all.min.js
// @code_url https://raw.github.com/lindell/JsBarcode/master/CODE128.js
// @code_url https://raw.github.com/lindell/JsBarcode/master/CODE39.js
// @code_url https://raw.github.com/lindell/JsBarcode/master/EAN_UPC.js
// @code_url https://raw.github.com/lindell/JsBarcode/master/ITF.js
// @code_url https://raw.github.com/lindell/JsBarcode/master/ITF14.js
// @code_url https://raw.github.com/lindell/JsBarcode/master/JsBarcode.js
// ==/ClosureCompiler==

About

Create different type of barcodes with javascript

License:MIT License