js export html to canvas image All In One
js export html to canvas image All In One
canvas.toDataURL
https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL
https://stackoverflow.com/questions/923885/capture-html-canvas-as-gif-jpg-png-pdf
Capture HTML Canvas as gif/jpg/png/pdf
?
https://stackoverflow.com/questions/923885/capture-html-canvas-as-gif-jpg-png-pdf
https://weworkweplay.com/play/saving-html5-canvas-as-image/
https://davidwalsh.name/convert-canvas-image
demo
https://jsfiddle.net/codepo8/V6ufG/2/
https://jsfiddle.net/user2314737/28wqq1gu/
https://www.html5canvastutorials.com/advanced/html5-canvas-save-drawing-as-an-image/
HTML to Image 实现原理:
-
在页面的底部追加 APP 自定义信息(水印, 背景图片)
-
获取页面的 scrollHeight & scrollWidth (最大宽高)
-
HTML to Canvas
-
Canvas to Image
-
auto download Image
-
preview Image (可选)
html & :root
let html = document.querySelector(`:root`);
html.scrollHeight;
html.innerText = html.innerText.split(' ').join('');
refs
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/11278677.html
未经授权禁止转载,违者必究!