本文主要是介绍开源介绍 - html2canvas,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
What is html2canvas ?
The script allows you to take “screenshots” of webpages or parts of it, directly on the users browser. The screenshot is based on the DOM and as such may not be 100% accurate to the real representation as it does not make an actual screenshot, but builds the screenshot based on the information available on the page.
这个脚本允许你自己对浏览器上的整个页面或部分进行截图,屏幕截图基于DOM元素进行,因此可能部署百分之百准确的真实表现,他并不是对屏幕截图,而是通过页面上的信息去构建屏幕截图。
注官网链接:https://html2canvas.hertzen.com/
How it works ?
The script traverses through the DOM of the page it is loaded on. It gathers information on all the elements there, which it then uses to build a representation of the page. In other words, it does not actually take a screenshot of the page but builds a representation of it based on the properties it reads from the DOM.
该脚本遍历它所加载的页面的 DOM。它收集那里所有元素的信息,然后使用这些信息来构建页面的表示。换句话说,它实际上并没有截取页面的屏幕截图,而是根据它从 DOM 读取的属性构建它的表示。
As a result, it is only able to render correctly properties that it understands, meaning there are many CSS properties which do not work. For a full list of supported CSS properties, check out the supported features page.
结果,它只能正确渲染它理解的属性,这意味着有许多 CSS 属性不起作用。有关支持的 CSS 属性的完整列表,请查看 支持的功能页面。
Limitations
All the images that the script uses need to reside under the same origin for it to be able to read them without the assistance of a proxy. Similarly, if you have other canvas elements on the page, which have been tainted with cross-origin content, they will become dirty and no longer readable by html2canvas.
脚本使用的所有图像都需要位于同一源下,以便无需代理 的帮助即可读取它们。同样,如果canvas 页面上有其他元素被跨域内容污染,它们将变脏并且不再被 html2canvas 读取。
The script doesn’t render plugin content such as Flash or Java applets.
该脚本不呈现插件内容,例如 Flash 或 Java 小程序。
这篇关于开源介绍 - html2canvas的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!