javascript - html2canvas screenshot capturing current window, not entire body -
trying capture screenshot of entire body of page (including fields filled in user) in javascript, html2canvas captures current window, when set height huge number. html2canvas website examples appear have desired functionality, i'm not able understand they're doing differently.
<button id="pdfbutton" type="button">click me!</button> <script type="text/javascript"> $( "#pdfbutton" ).click(function() { html2canvas(document.body, { onrendered: function(canvas) { // document.body.appendchild(canvas); var img = canvas.todataurl("image/png"); console.log(img); document.body.appendchild(canvas); } // height: 10000 }); }); </script>
please let me know if there other ways capture screenshot on button click in javascript (without inserting url, because user fills in fields on page).
solved problem removing style attribute (height, position) not support html2canvas , adding after capturing screenshot. in case faced problem position.
$('.element').css('position','initial'); // change absolute initial $my_view = $('#my-view'); var useheight = $('#my-view').prop('scrollheight'); html2canvas($my_view[0], { height: useheight, usecors: true, allowtaint: true, proxy: "your proxy url", onrendered: function (canvas) { var imgsrc = canvas.todataurl(); var popup = window.open(imgsrc); $('.element').css('position','absolute'); } });
this take screenshot of whole screen including scrollable part. check solution
Comments
Post a Comment