Skip to content
Johan Lindell edited this page Sep 20, 2016 · 1 revision

.init()

The .init() function provides a way to specify the options of the rendering in HTML instead of the parameters. Just set HTML attributes as jsbarcode-* or data-* where * is any of the JsBarcode options.

Example HTML:

<svg class="barcode"
  jsbarcode-format="upc"
  jsbarcode-value="123456789012"
  jsbarcode-textmargin="0"
  jsbarcode-fontoptions="bold">
</svg>

And then initialize it with:

JsBarcode(".barcode").init();

Options with .init()

If you want to generalize some options to all of the initialized barcodes you can do that by first calling the options function.

Example:

JsBarcode(".barcode").options({
  width: 1,
  height: 25,
  margin: 0
}).init();
Clone this wiki locally