javascriptbarcodebarcode-printing

How to make a small QR with javascript


I have a link I want to put in my barcode (google authenticator link). I am currently using the JsBarcode lib but it seems like the barcode is just too wide and the barcode scanner can't recognize itenter image description here

my configuration:

JsBarcode("#barcode", data,{
              displayValue: false,
              width: 1,
            });

I was wondering if there is a way to minimize it even more(because by their documentary the smallest size is 1) or a different way to solve this


Solution

  • Ok, so I ended up using a different library.

    Link:
    
    <script type="text/javascript" src="{{ url_for('static', filename='qrcode.min.js') }}" defer></script> // jinja2
    

    JS code:
    
        var qrcode = new QRCode(document.querySelector("#barcode"), { // have to select a query like this
                      text: data,
                      width: 128,
                      height: 128,
                      colorDark : "#000000",
                      colorLight : "#ffffff",
                      correctLevel : QRCode.CorrectLevel.H
                    });
    

    The HTML code has an empty div. Result:enter image description here(without the red marker ofcurse)