JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 258
  • Score
    100M100P100Q90161F
  • License MIT

JavaScript barcode generator supporting over 90 types and standards.

Package Exports

  • bwip-angular2

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (bwip-angular2) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

metafloor/bwip-js library modification for Angular2+.

Installation

npm install bwip-angular2

After the installation of the library you must copy the folder "fonts" from 'node_modules/bwip-js/' to the '/src/assets' and rename it (the folder "fonts") to "bwipjs-fonts"

Usage

import { Component } from '@angular/core';
import bwipjs from 'bwip-angular2';

@Component({
  selector: 'barcode',
  template: '<canvas id="barcodeCanvas"></canvas><div id="err"></div>',
  styleUrls: ['./barcode.component.css']
})
export class BarcodeComponent  {

  constructor() {
      bwipjs('barcodeCanvas', {
        bcid: 'datamatrix',       // Barcode type
        text: '123456789',   	  // Text to encode
        scale: 3,                 // 3x scaling factor
        height: 10,               // Bar height, in millimeters
        width: 10,
        includetext: true,        // Show human-readable text
        textxalign: 'center',      // Always good to set this
      }, function (err, cvs) {
        if (err) {
          document.getElementById('err').innerText = 'Error occured. See browser log for more information';
          console.log(err);
        } else {
        }
      });
   }
}

For more information and barcode options see Barcode Writer in Pure PostScript.