Generate barcode from text and convert it to base64

前端 未结 2 1919
说谎
说谎 2021-02-19 11:55

Does someone knows a tool to generate barcode image (preferably code 39) from a string and converts it to base64 string, something to use like this:

var text =         


        
2条回答
  •  走了就别回头了
    2021-02-19 12:43

    Using JsBarcode this function will do what you want.

    function textToBase64Barcode(text){
      var canvas = document.createElement("canvas");
      JsBarcode(canvas, text, {format: "CODE39"});
      return canvas.toDataURL("image/png");
    }
    

提交回复
热议问题