This commit is contained in:
2020-09-14 22:58:39 +00:00
parent 659ea0e620
commit e44f6b2ef7

View File

@@ -92,15 +92,10 @@ function ayRegisterHelpers() {
return ayTranslationKeyCache[translationKey];
});
/*
let canvas = document.createElement('canvas');
try {
bwipjs.toCanvas(canvas, options);
document.getElementById(myimg).src = canvas.toDataURL('image/png');
} catch (e) {
// `e` may be a string or Error object
}
*/
///////////////////////////////////////////
// BarCode helper using
// https://github.com/metafloor/bwip-js#browser-usage
//
Handlebars.registerHelper("ayBC", function (text, options) {
let canvas = document.getElementById("aybarcode");
if (canvas == null) {
@@ -114,21 +109,7 @@ try {
text = text.toString();
}
opt.text = text;
opt.textxalign = "center";
if (opt.pad && opt.text) {
//pad out the code by inserting leading zeros to the specified length
opt.text = ayPad(opt.text, opt.pad, 0);
}
// let opt = {
// bcid: "code128", // Barcode type
// text: "0123456789", // 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
// };
opt.textxalign = opt.textxalign || "center";
bwipjs.toCanvas(canvas, opt);
var url = canvas.toDataURL("image/png");