Skip to content Skip to sidebar Skip to footer

Converting Div And Its Associated Elements To Canvas Jquery?

Is there any way to convert HTML Div and its associated elements to canvas and the canvas to image Using Jquery? I already had a look on following website, It would only convert wh

Solution 1:

Sorry, the browser won't render HTML into a canvas.

It would be a potential security risk if you could, as HTML can include content (in particular images and iframes) from third-party sites. If canvas could turn HTML content into an image and then you read the image data, you could potentially extract privileged content from other sites.

To get a canvas from HTML, you'd have to basically write your own HTML renderer from scratch using drawImage and fillText, which is a potentially huge task. There's one such attempt here but it's a bit dodgy and a long way from complete. (It even attempts to parse the HTML/CSS from scratch, which I think is crazy! It'd be easier to start from a real DOM node with styles applied, and read the styling using getComputedStyle and relative positions of parts of it using offsetTop et al.)

Post a Comment for "Converting Div And Its Associated Elements To Canvas Jquery?"