1.2.1 • Published 3 years ago

@tecuity/barcode-generator v1.2.1

Weekly downloads
73
License
MIT
Repository
github
Last release
3 years ago

npm.io

barcode-generator npm.io npm.io npm.io

Ever needed to generate a barcode in a JS-only environment? barcode-generator generates SVG barcodes in a browser, NodeJS, or anywhere else Javascript can run.

Features:

  • Javascript-only. No canvas or browser emulator needed
  • Support for the common 3 of 9 format
  • Returns a barcode as a base64 data url, or raw SVG
  • Zero dependencies

Demo Site

View a demo here

Installation

npm install @tecuity/barcode-generator

or

yarn add @tecuity/barcode-generator

Usage

For a default usage, just import and call the generator with a string like this:

import generateBarcode from '@tecuity/barcode-generator'

const barcode = generateBarcode("1234567")

And that's it! By default the generator will return a barcode as a base64-encoded data url. Ready to pop into the src attribute of an img element.

For further customization, you can pass an options object as the second parameter of the function like so:

import generateBarcode from '@tecuity/barcode-generator'

const barcode = generateBarcode("1234567", {raw: true, spacing: 10})

API Reference:

KeyTypeDefaultDescription
spacingint || float5The spacing between characters, relative to the viewBox of the resulting SVG.
rawbooleanfalseReturns the barcode as a raw SVG string rather than a base64 data-url.
heightint || float172.89The viewBox height of the resulting SVG.

Contributors ✨

This project follows the all-contributors specification. Contributions of any kind welcome!

1.2.1

3 years ago

1.2.0

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago