I started working with HTML2Canvas a few days ago and with some research, I managed to code a little script with which I can save a specific HTML div as a png. (I'm saving a table here)
The image I get from the desktop.
But the issue is, when I take the screenshot from mobile view, it shows the element as it is.
Now I know the canvas will paint the screen/div as displayed but I want to save the whole table instead of half scrolled. Is there any way to do this without changing the style of the table?
Code
$(document).on('click', '#takePic', function(){
html2canvas(document.getElementById("final_order"),{
allowTaint: true,
useCORS: true,
})
.then(function(canvas) {
var base64URL = canvas.toDataURL('image/jpeg').replace('image/jpeg', 'image/octet-stream');
$.ajax({
url: 'save-image.php',
type: 'post',
data: {action: "download",image: base64URL},
success: function(data){
alert("Success");
}
});
});
});
Any assistance or guidance would be greatly appreciated.