xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

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 实现原理:

  1. 在页面的底部追加 APP 自定义信息(水印, 背景图片)

  2. 获取页面的 scrollHeight & scrollWidth (最大宽高)

  3. HTML to Canvas

  4. Canvas to Image

  5. auto download Image

  6. 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, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2019-07-31 19:48  xgqfrms  阅读(213)  评论(11编辑  收藏  举报