diff --git a/zpl2svg.js b/zpl2svg.js index 78d1b86..c29a012 100644 --- a/zpl2svg.js +++ b/zpl2svg.js @@ -89,7 +89,7 @@ svg.push(``) svg.push(``) svg.push(``) - + // Track inversion regions let inversionMasks = [] @@ -211,7 +211,7 @@ rotate: state.barcode.orientation === 'B' ? 'L' : state.barcode.orientation, } if (alttext && state.barcode.print_human_readable) barcode_options.alttext = alttext - if (bcid === 'azteccode') { + if (bcid === 'azteccode') { // @ts-ignore delete barcode_options.height barcode_options.scale *= state.barcode.magnification / 4 barcode_options.format = 'full' @@ -229,7 +229,15 @@ } // @ts-ignore - const barcode = bwipjs.toSVG(barcode_options) + let barcode = '' + try { + barcode = bwipjs.toSVG(barcode_options) + } catch (e) { + console.log(`Failed to generate barcode: ${state.barcode.type} with value: ${value}`) + console.log(e) + state.barcode.type = '' // Reset barcode type to prevent drawing barcode on next text field + break + } //