JavaScript barcode generator supporting over 90 types and standards.
npm install bwip-angular2
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
`javascript
import { Component } from '@angular/core';
import bwipjs from 'bwip-angular2';
@Component({
selector: 'barcode',
template:
,
styleUrls: ['./barcode-component.sass']
})
export class BarcodeComponent {
public renderBarcode(): void {
bwipjs('barcodeCanvas', {
bcid: 'code128', // Barcode type
text: '987654321', // 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
}, (err, cvs) => {
if (err) {
document.getElementById('err').innerText = 'Error occured. See browser log for more information';
console.log(err);
} else {
}
});
}
}
``