html2canvas
===========
[Homepage](http://html2canvas.hertzen.com) | [Downloads](https://github.com/niklasvh/html2canvas/releases) | [Questions](http://stackoverflow.com/questions/tagged/html2canvas?sort=newest) | [Donate](https://www.gittip.com/niklasvh/)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/niklasvh/html2canvas?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Build Status](https://travis-ci.org/niklasvh/html2canvas.png)](https://travis-ci.org/niklasvh/html2canvas)
#### JavaScript HTML renderer ####
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.
###How does it work?###
The script renders the current page as a canvas image, by reading the DOM and the different styles applied to the elements.
It does **not require any rendering from the server**, as the whole image is created on the **clients browser**. However, as it is heavily dependent on the browser, this library is *not suitable* to be used in nodejs.
It doesn't magically circumvent any browser content policy restrictions either, so rendering cross-origin content will require a [proxy](https://github.com/niklasvh/html2canvas/wiki/Proxies) to get the content to the [same origin](http://en.wikipedia.org/wiki/Same_origin_policy).
The script is still in a **very experimental state**, so I don't recommend using it in a production environment nor start building applications with it yet, as there will be still major changes made.
###Browser compatibility###
The script should work fine on the following browsers:
* Firefox 3.5+
* Google Chrome
* Opera 12+
* IE9+
* Safari 6+
As each CSS property needs to be manually built to be supported, there are a number of properties that are not yet supported.
### Usage ###
**Note!** These instructions are for using the current dev version of 0.5, for the latest release version (0.4.1), checkout the [old readme](https://github.com/niklasvh/html2canvas/blob/v0.4/readme.md).
To render an `element` with html2canvas, simply call:
` html2canvas(element[, options]);`
The function returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) containing the `<canvas>` element. Simply add a promise fullfillment handler to the promise using `then`:
html2canvas(document.body).then(function(canvas) {
document.body.appendChild(canvas);
});
### Building ###
The library uses [grunt](http://gruntjs.com/) for building. Alternatively, you can download the latest build from [here](https://github.com/niklasvh/html2canvas/blob/master/dist/html2canvas.js).
Clone git repository with submodules:
$ git clone --recursive git://github.com/niklasvh/html2canvas.git
Install Grunt and uglifyjs:
$ npm install -g grunt-cli uglify-js
Run the full build process (including lint, qunit and webdriver tests):
$ grunt
Skip lint and tests and simply build from source:
$ grunt build
### Running tests ###
The library has two sets of tests. The first set is a number of qunit tests that check that different values parsed by browsers are correctly converted in html2canvas. To run these tests with grunt you'll need [phantomjs](http://phantomjs.org/).
The other set of tests run Firefox, Chrome and Internet Explorer with [webdriver](https://github.com/niklasvh/webdriver.js). The selenium standalone server (runs on Java) is required for these tests and can be downloaded from [here](http://code.google.com/p/selenium/downloads/list). They capture an actual screenshot from the test pages and compare the image to the screenshot created by html2canvas and calculate the percentage differences. These tests generally aren't expected to provide 100% matches, but while commiting changes, these should generally not go decrease from the baseline values.
Start by downloading the dependencies:
$ npm install
Run qunit tests:
$ grunt test
### Examples ###
For more information and examples, please visit the [homepage](http://html2canvas.hertzen.com) or try the [test console](http://html2canvas.hertzen.com/screenshots.html).
### Contributing ###
If you wish to contribute to the project, please send the pull requests to the develop branch. Before submitting any changes, try and test that the changes work with all the support browsers. If some CSS property isn't supported or is incomplete, please create appropriate tests for it as well before submitting any code changes.
没有合适的资源?快使用搜索试试~ 我知道了~
保存网页div块为图片
共152个文件
html:81个
js:48个
htm:4个
5星 · 超过95%的资源 需积分: 50 41 下载量 185 浏览量
2017-11-18
16:18:37
上传
评论
收藏 579KB RAR 举报
温馨提示
保存网页上的指定块为图片,保存网页上的指定块为图片,保存网页上的指定块为图片,保存网页上的指定块为图片,保存网页上的指定块为图片。(我只为例凑够50字)
资源推荐
资源详情
资源评论
收起资源包目录
保存网页div块为图片 (152个子文件)
mocha.css 4KB
.gitignore 119B
.gitignore 13B
.gitmodules 91B
proxy.htm 3KB
iframe2.htm 459B
iframe1.htm 436B
iframe3.htm 394B
acid2.html 14KB
radial-gradient.html 10KB
parsing.html 10KB
linear-gradient.html 7KB
form-rendering.html 6KB
cropping.html 6KB
text.html 5KB
chinese.html 5KB
encoded.html 5KB
background.html 5KB
demo.html 4KB
scrolling.html 4KB
forms.html 3KB
native_only.html 3KB
options.onclone.html 3KB
multiple-renders.html 3KB
overflow.html 3KB
z-index10.html 3KB
z-index3.html 3KB
clip.html 2KB
z-index18.html 2KB
z-index2.html 2KB
z-index9.html 2KB
z-index7.html 2KB
z-index8.html 2KB
ie9-clonenode-bug.html 2KB
position.html 2KB
rotate.html 2KB
z-index1.html 2KB
radius.html 2KB
repeat.html 2KB
size.html 2KB
translate.html 2KB
clip.html 2KB
demo2.html 2KB
base64.html 1KB
existing_canvas.html 1KB
fontawesome.html 1KB
nested.html 1KB
multi.html 1KB
pseudoelements.html 1KB
linethrough.html 1KB
underline.html 1KB
underline-lineheight.html 1KB
inline.html 1KB
node.html 1KB
inset.html 1KB
images.html 1KB
lower-alpha.html 1KB
decimal.html 1KB
upper-roman.html 1KB
decimal-leading-zero.html 1KB
shadow.html 1KB
google-maps.html 1KB
z-index11.html 1KB
z-index12.html 1KB
rangetest.html 990B
dashed.html 936B
dotted.html 936B
solid.html 935B
double.html 935B
visibility.html 836B
z-index16.html 827B
z-index4.html 806B
z-index5.html 769B
z-index6.html 746B
canvas.html 738B
z-index13.html 698B
image.html 677B
z-index15.html 628B
empty.html 603B
z-index14.html 602B
child-textnodes.html 584B
demo3.html 522B
z-index17.html 519B
base.html 509B
cross-origin.html 465B
external.html 367B
crossorigin-iframe.html 322B
frame1.html 260B
iframe.html 236B
image2_1.jpg 4KB
image2.jpg 4KB
image.jpg 3KB
image_1.jpg 3KB
html2canvas.svg.js 547KB
jquery.js 262KB
jquery-1.6.2.js 231KB
html2canvas.svg.min.js 179KB
html2canvas.js 151KB
html2canvas.js 151KB
mocha.js 128KB
共 152 条
- 1
- 2
资源评论
- liang21952019-03-14谢谢分享!
- 罗网科技刘润东2018-04-26资源不错,解决了我的问题
aoxiaomiao88
- 粉丝: 1
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功