html to jpg javascript

Admin
1 minute read
0


 

 html to jpg javascript

 

आप बहुत ही आसानी से अपनी HTML Code को JPG ya किसी भी और फॉर्मेट में आसानी से एक क्लिक से डाउनलोड कर सकते है और वो भी बहुत ही आसानी से तो देर किस बात की

कोड को उपयोग करे और आनंदित रहे 

You can very easily download your HTML Code in JPG or any other format with just one click and that too very easily then what is the delay. use the code and enjoy


Code Start :

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"></script>
</head>
<body>
<div id="content">
  <center>
 
  <h1> Html to Photo </h1>
 
  <br/><br/><br/><br/><br/>
  <p> Demo text for digital dunia</p>

 <br/><br/><br/><br/><br/>
<button id="download-page-as-image">Click to Download</button>

</center>
</div>

<script>
$(document).ready(function(){
 
setUpDownloadPageAsImage();

function setUpDownloadPageAsImage() {
  document.getElementById("download-page-as-image").addEventListener("click", function() {
    html2canvas(document.body).then(function(canvas) {
      console.log(canvas);
      simulateDownloadImageClick(canvas.toDataURL(), 'file-name.png');
    });
  });
}

function simulateDownloadImageClick(uri, filename) {
  var link = document.createElement('a');
  if (typeof link.download !== 'string') {
    window.open(uri);
  } else {
    link.href = uri;
    link.download = filename;
    accountForFirefox(clickLink, link);
  }
}

function clickLink(link) {
  link.click();
}

function accountForFirefox(click) { // wrapper function
  let link = arguments[1];
  document.body.appendChild(link);
  click(link);
  document.body.removeChild(link);
}    
    
    

});

</script>
</body>
</html>        


Code End:               

Tags

Post a Comment

0 Comments
Post a Comment (0)
Our website uses cookies to fast experience.
Accept !