<!DOCTYPE html>
<html lang="en">
<head>
<meta charset = "UTF-8">
<meta name = "viewport" content = "width=device-width, initial-scale=1.0">
<meta http-equiv = "X-UA-Compatible" content = "ie=edge">
<link href = "https://fonts.googleapis.com/css?family=Major+Mono+Display" rel = "stylesheet">
<link rel = "stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src = "https://cdnjs.cloudflare.com/ajax/libs/qrcode-generator/1.4.1/qrcode.js"> </script>
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"> </script>
<link rel = "stylesheet" href = "https://use.fontawesome.com/releases/v5.6.1/css/all.css" integrity="sha384-gfdkjb5BdAXd+lj+gudLWI+BXq4IuLW5IT+brZEZsLFm++aCMlF1V92rMkPaX4PP" crossorigin = "anonymous">
<script src = "https://cdnjs.cloudflare.com/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js"> </script>
<script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"> </script>
<link rel="stylesheet" href="QR generator.css">
<title> Developer Corner QR Generator </title>
</head>
<body>
<h2> Developer Corner QR Code Generator </h2>
<div class = "container mx-auto w-75 py-4 border my-4 bg-light">
<label for = "usr" class = "text-dark"> Enter Text: </label>
<input type = "text" class = "form-control" id = "text" name = "username" placeholder = "Enter Text Here">
<a href = "javascript:void(0)" class = "btn btn-primary btn-lg my-4" onclick = "generate();"> Generate </a>
</div>
<div class = "jumbotron mx-auto w-75 border my-4 py-4 text-center" id = "dBtn">
<div id = "placeHolder"> </div>
<canvas id = "myCanvas"> </canvas>
<br>
<a href = "#" class = "btn btn-danger btn-lg" onclick = "downloadQrCode(this);" download = "QRcode.png" > Download </a>
</div>
<nav class = "navbar navbar-expand-sm bg-dark navbar-dark fixed-bottom p-1 ">
<ul class = "navbar-nav">
<li class = "nav-item">
<a class = "nav-link" href = "javascript:void(0)"> Developer Corner All Rights Reserved 2022 </a>
</li>
</ul>
</nav>
<script>
function generate(){
var typeNumber = 4;
var errorCorrectionLevel = 'L';
var qr = qrcode(typeNumber, errorCorrectionLevel);
var inputText = document.getElementById('text').value;
qr.addData(inputText);
qr.make();
document.getElementById('placeHolder').innerHTML = qr.createImgTag();
canvasScreen();
}
downloadQrCode =function (el){
var canvas = document.getElementById("myCanvas");
var image = canvas.toDataURL("image/png");
el.href = image;
};
function canvasScreen() {
var a = document.getElementsByTagName("img")[0];
a.setAttribute("id","qrcode");
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
var img = document.getElementById("qrcode");
ctx.drawImage(img,70,0,150,150);
document.getElementById("dBtn").style.display = "block";
}
</script>
</body>
</html>
0 Comments (Please let us know your query)