Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to save specific part of page as image using JavaScript

I have create grid using JavaScript and I want to save that grid with some dropped image as a image. here is my link

like image 646
Moumita Avatar asked Nov 14 '22 01:11

Moumita


1 Answers

If you can restrict this usage to browsers using canvas elements, and with firefox extensions -- so firefox in fact, you can load any part of the DOM in a canvas and extract image for the canvas. Basically:

canvas = document.getElementById("#acanvas"); 
if (canvas.getContext) {
    var context = canvas.getContext('2d');
    context.drawWindow(here_any_part_of_the_DOM_tree_not_only_window);
    var mypng = context.toDataURL();
}
like image 166
regilero Avatar answered Dec 22 '22 05:12

regilero