jqueryqr-code

QR Code using Jquery


I am having a form on which i have displayed QR Code, And using printThis.js to print the form. QR code was previously displayed and printed easily using google URL but i found that it has been depreciated, Then i googled to find other source and found jquery libraries jquery.qrcode.js and qrcode.js, But now i am facing a problem when i am printing the form QR code is not displaying on it, Probably its displaying QR code as canvas, Here is my code

HTML

<img id="test"></div>

JQUERY

$(document).ready(function(){
     $('#test').qrcode({width: 120,height: 120, text: "Sample QR"});
        printthis();
})

How i can make it printable, And secondly let me know if it will work for all browsers are not? And do we have any other solution like google url


Solution

  • <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1/jquery.min.js"></script>
        <script type="text/javascript" src="jquery-qrcode-0.14.0.js"></script>
    </head>
    <body>
        <div id="qrcode"></div>
        <script type="text/javascript">
        var options = {
            // render method: 'canvas', 'image' or 'div'
            render: 'canvas',
    
            // version range somewhere in 1 .. 40
            minVersion: 1,
            maxVersion: 40,
    
            // error correction level: 'L', 'M', 'Q' or 'H'
            ecLevel: 'L',
    
            // offset in pixel if drawn onto existing canvas
            left: 0,
            top: 0,
    
            // size in pixel
            size: 200,
    
            // code color or image element
            fill: '#000',
    
            // background color or image element, null for transparent background
            background: null,
    
            // content
            text: 'no text',
    
            // corner radius relative to module width: 0.0 .. 0.5
            radius: 0,
    
            // quiet zone in modules
            quiet: 0,
    
            // modes
            // 0: normal
            // 1: label strip
            // 2: label box
            // 3: image strip
            // 4: image box
            mode: 0,
    
            mSize: 0.1,
            mPosX: 0.5,
            mPosY: 0.5,
    
            label: 'no label',
            fontname: 'sans',
            fontcolor: '#000',
    
            image: null
        }
        $('#qrcode').qrcode(options);
        </script>
    </body>
    </html>