Drawing HTML on canvas

With the advent of the new HTML5 Canvas, I was wondering if it is possible to draw an HTML section on a canvas?

The idea is to take a piece of existing HTML code (from the same page or defined elsewhere) and turn it into graphics.

Sort of:

htContext.drawElement(document.getObjectByID("someObj"),0,0); 
+4
source share
1 answer

Firefox has its own drawWindow method. With it, you can draw the entire document on canvas. But only in Firefox, unfortunately. And also because of security issues, you need permissions from the user. Therefore, it is suitable only for its internal project.

Here is a sample test page:

 <!DOCTYPE html> <html> <head> <title>drawWindow</title> <script> window.onload = function(){ netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead'); document.getElementById('canvas').getContext('2d').drawWindow(window, 0, 0, 100, 200, "rgb(255,255,255)"); } </script> </head> <body> <h1>Test</h1> <canvas id="canvas"></canvas> </body> </html> 
+3
source

All Articles