JsBarcode icon indicating copy to clipboard operation
JsBarcode copied to clipboard

Barcode value is being cut off

Open danny-andrews-snap opened this issue 6 years ago • 3 comments

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

image

Actual

image

(Notice the barcode value being cut off at the bottom.)

danny-andrews-snap avatar Feb 22 '19 17:02 danny-andrews-snap

What browser are you using. Please provide a clear way to reproduce this problem

lindell avatar Feb 25 '19 17:02 lindell

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.

danny-andrews-snap avatar Feb 25 '19 17:02 danny-andrews-snap

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
});

GitBruno avatar Aug 07 '19 12:08 GitBruno