Rendering HTML elements to

前端 未结 6 2138
天命终不由人
天命终不由人 2020-11-28 03:53

Is there a way to have an arbitrary HTML element rendered in a canvas (and then access its buffer...).

6条回答
  •  天命终不由人
    2020-11-28 04:11

    You won't get real HTML rendering to per se currently, because canvas context does not have functions to render HTML elements.

    There are some emulations:

    html2canvas project http://html2canvas.hertzen.com/index.html (basically a HTML renderer attempt built on Javascript + canvas)

    HTML to SVG to might be possible depending on your use case:

    https://github.com/miohtama/Krusovice/blob/master/src/tools/html2svg2canvas.js

    Also if you are using Firefox you can hack some extended permissions and then render a DOM window to

    https://developer.mozilla.org/en-US/docs/HTML/Canvas/Drawing_Graphics_with_Canvas?redirectlocale=en-US&redirectslug=Drawing_Graphics_with_Canvas#Rendering_Web_Content_Into_A_Canvas

提交回复
热议问题