Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsbarcode

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsbarcode

JsBarcode is a customizable barcode generator with support for multiple barcode formats.

  • 3.11.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
335K
decreased by-12.31%
Maintainers
1
Weekly downloads
 
Created

What is jsbarcode?

The jsbarcode npm package is a versatile library for generating barcodes in various formats. It supports multiple barcode types and can be used in both Node.js and browser environments. The package is highly customizable, allowing users to adjust the appearance and format of the generated barcodes.

What are jsbarcode's main functionalities?

Generate Barcode in HTML

This feature allows you to generate a barcode and embed it in an HTML image element. The code uses the 'canvas' module to create a canvas element, which is then used by JsBarcode to draw the barcode.

const JsBarcode = require('jsbarcode');
const { createCanvas } = require('canvas');

const canvas = createCanvas();
JsBarcode(canvas, '123456789012', { format: 'CODE128' });
console.log('<img src="' + canvas.toDataURL() + '" />');

Generate Barcode in SVG

This feature allows you to generate a barcode in SVG format. The code uses the 'xmldom' module to create an SVG document, which is then used by JsBarcode to draw the barcode.

const JsBarcode = require('jsbarcode');
const { DOMImplementation, XMLSerializer } = require('xmldom');

const document = new DOMImplementation().createDocument(null, 'svg', null);
const svgNode = document.documentElement;
JsBarcode(svgNode, '123456789012', { format: 'CODE128' });
const svgString = new XMLSerializer().serializeToString(svgNode);
console.log(svgString);

Customizing Barcode Appearance

This feature allows you to customize the appearance of the barcode. You can change the line color, width, height, and whether to display the value below the barcode.

const JsBarcode = require('jsbarcode');
const { createCanvas } = require('canvas');

const canvas = createCanvas();
JsBarcode(canvas, '123456789012', {
  format: 'CODE128',
  lineColor: '#0aa',
  width: 4,
  height: 40,
  displayValue: true
});
console.log('<img src="' + canvas.toDataURL() + '" />');

Other packages similar to jsbarcode

Keywords

FAQs

Package last updated on 14 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc