JsBarcode
JsBarcode copied to clipboard
Barcode value is being cut off
Problem
It looks like this library doesn't calculate the viewbox properly when rendering a jagged UPC barcode with the value printed underneath.
Example
JsBarcode('#barcode', '673006885997', {
format: 'UPC',
width: 2,
height: 32
});
Expected
Actual
(Notice the barcode value being cut off at the bottom.)
What browser are you using. Please provide a clear way to reproduce this problem
I really tried hard to do just that. 🤷♂️ The example I gave is a minimal case to reproduce this problem.
Don't think the browser matters because the values are incorrect, but fwiw I tried it on latest version of Chrome.
Viewbox is on the baseline and does not take overhang of a font into account. Just set a custom margin for the bottom (you could link this to selected font):
JsBarcode('#barcode', '673006885997', {
format: 'UPC',
width: 2,
height: 32,
marginBottom: 2
});