leumas-universal-crud-react
Version:
Leumas Universal CRUD to a dynamic Endpoint, Setup your own Dynamic Endpoint and Use Leumas API to send to your MONGO clusters
23 lines (20 loc) • 750 B
JSX
// generateBarcode.jsx
import bwipjs from 'bwip-js';
export const generateBarcode = (canvasRef, barcodeValue) => {
if (!canvasRef.current) {
console.error('Canvas reference is not valid');
return;
}
try {
bwipjs.toCanvas(canvasRef.current, {
bcid: 'code128', // Barcode type
text: barcodeValue, // Text to encode
scale: 3, // 3x scaling factor
height: 10, // Bar height, in millimeters
includetext: true, // Show human-readable text
textxalign: 'center', // Always good to set this
});
} catch (err) {
console.error('Error generating barcode:', err);
}
};