arvind baldaniya

arvind baldaniya

  • NA
  • 339
  • 141.2k

Convert html content into image using jquery

Oct 9 2017 7:09 AM
Below My code....My code is perfectly working but one issue.. Background images is not working How to set Background Images
  1. <script type="text/javascript">  
  2. function CreateFrame(emailFrame, Desc) {  
  3. $("#lblFrameEmail").text(emailFrame);  
  4. $("#lblFrameDesc").text(Desc);  
  5. var frameHtml = $("#test").html();  
  6. var canvas = document.getElementById('canvas');  
  7. var ctx = canvas.getContext('2d');  
  8. var data = '<svg xmlns="http://www.w3.org/2000/svg" width="800" height="800">' +  
  9. '<foreignObject width="100%" height="100%">' +  
  10. '<div xmlns="http://www.w3.org/1999/xhtml" id="test" style="height:400px;width:600px;">' +  
  11. '<img src="http://localhost:2359/Assets/img/FeedbackBack.png" />'+  
  12. '<label style="padding-left:218px;padding-top:26px;font-size:23px;position:absolute;right: 33%;top: -7.5%;margin-top: 30px;" id="lblFrameEmail"> [email protected]</label>' +  
  13. '<h3 style="padding-left:40px;padding-top:55px;padding-right:55px;font-family:Lucida Calligraphy;color:#080505;position: absolute;top: 30px;margin-top: 30px;" id="lblFrameDesc">The person who sent a feedback can only reply when the recipient has given a reply on that feedback at least once.When new response on old feedback is received, move the feedback on top of the list and highlight the subject line (Similar to new “Feedback Received” event).</h3>'+  
  14. '</div>' +  
  15. '</foreignObject>' +  
  16. '</svg>';  
  17. var DOMURL = window.URL || window.webkitURL || window;  
  18. var img = new Image();  
  19. var svg = new Blob([data], { type: 'image/svg+xml' });  
  20. var url = DOMURL.createObjectURL(svg);  
  21. img.onload = function () {  
  22. ctx.drawImage(img, 0, 0);  
  23. DOMURL.revokeObjectURL(url);  
  24. }  
  25. img.src = url  
  26. $("#imgFrame").attr("src", url);  
  27. }  
  28. </script> 

Answers (1)