50
Views
7
Comments
Solved
[Script Barcode] Create barcode using script
Application Type
Traditional Web

I want to create a barcode using a script "Traditional Web" (I don't want to use Forge components) What is the best way? 


2022-05-19 09-39-13
David Sousa
Solution

As I suspected, the JS resource isn't being loaded, hence the error "JsBarcode is not defined".

Please check that the path in the JS resource matches the path of the script src.

2022-05-19 09-39-13
David Sousa

Hi Raquel,

This is an easy to use JS library that generates bar codes https://lindell.me/JsBarcode/.

Cheers

2023-03-18 19-02-28
Raquel Gomes

Hi David !!

I created the script below, in my personal environment it is working perfectly, however in the business environment the barcode does not appear.

Do you have any idea what's going on?


"

"<script src='../BarcodeGenerator/js/BarcodeGenerator.JS' type='text/javascript'></script>
<svg id ='barcodeSvg'></svg>
<script type='text/javascript'>
JsBarcode('#" + BarcodeContainer.Id + " #barcodeSvg', '" + EncodeJavaScript(BarcodeValue) + "', {
  format: '" + Format + "',
  width: " + Width + ",
  height: " + Height + ",
  displayValue: " + ToLower(BooleanToText(DisplayValue)) + ",
  text: '" + Text + "',
  fontOptions: '" + FontOptions + "',
  font: '" + Font + "',
  textAlign: '" + TextAlign + "',
  textPosition: '" + TextPosition + "',
  textMargin: " + TextMargin + ",
  fontSize: " + FontSize + ",
  background: '" + Background + "',
  lineColor: '" + LineColor + "',
  margin: " + Margin + ",
  marginTop: " + MarginTop + ",
  marginBottom: " + MarginBottom + ",
  marginLeft: " + MarginLeft + ",
  marginRight: " + MarginRight + ",
  valid: " + Valid + "
});  
</script>"

"

2022-05-19 09-39-13
David Sousa

Hi again,

Please doublecheck the following:

1) Do you have any errors in the browser console?

2) Is the script source correct in the business environment? Does the JS resource have the correct deploy action?

Another thing I noticed is that if you are already adding a SVG element in the script, you don't need to have another container to render the barcode.

Hope it helps you sort the problem!

Cheers

2023-03-18 19-02-28
Raquel Gomes
2022-05-19 09-39-13
David Sousa
Solution

As I suspected, the JS resource isn't being loaded, hence the error "JsBarcode is not defined".

Please check that the path in the JS resource matches the path of the script src.

2023-03-18 19-02-28
Raquel Gomes

I modified the path of the script src and it worked

Thanks

2021-06-13 07-48-30
Jerah

Hi i am looking for something like this , can someone share with me how do you implement this.

Thank you in advance :)

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.