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 library should work fine on the following browsers (with `Promise` polyfill):
* 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 ###
The html2canvas library utilizes `Promise`s and expects them to be available in the global context. If you wish to
support [older browsers](http://caniuse.com/#search=promise) that do not natively support `Promise`s, please include a polyfill such as
[es6-promise](https://github.com/jakearchibald/es6-promise) before including `html2canvas`.
**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.
没有合适的资源?快使用搜索试试~ 我知道了~
html2canvas网页截图自行工具接口
共150个文件
html:79个
js:45个
htm:4个
需积分: 0 1 下载量 161 浏览量
2023-03-08
11:58:36
上传
评论
收藏 489KB ZIP 举报
温馨提示
加载js文件对当前页面的固定区域进行截图,保存base64格式的图片文件的工具接口
资源推荐
资源详情
资源评论
收起资源包目录
html2canvas网页截图自行工具接口 (150个子文件)
mocha.css 4KB
.editorconfig 350B
.gitignore 133B
.gitignore 13B
.gitmodules 91B
proxy.htm 3KB
iframe2.htm 459B
iframe1.htm 436B
iframe3.htm 394B
acid2.html 14KB
parsing.html 13KB
radial-gradient.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
scrolling.html 4KB
demo.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
ie9-clonenode-bug.html 2KB
z-index8.html 2KB
position.html 2KB
rotate.html 2KB
radius.html 2KB
z-index1.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
decimal.html 1KB
upper-roman.html 1KB
lower-alpha.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
dotted.html 936B
dashed.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
z-index15.html 628B
empty.html 603B
z-index14.html 602B
child-textnodes.html 584B
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_1.jpg 3KB
image.jpg 3KB
html2canvas.svg.js 547KB
jquery-1.6.2.js 231KB
html2canvas.svg.min.js 179KB
mocha.js 128KB
html2canvas.js 123KB
html2canvas.min.js 59KB
nodeparser.js 36KB
expect.js 36KB
共 150 条
- 1
- 2
资源评论
给我一粒布洛芬
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于C++实现的全景图像拼接源码(课程设计)
- 基于SIFT特征点提取和RASIC算法实现全景图像拼接python源码+文档说明+界面截图+详细注释(95分以上课程大作业)
- 基于matlab实现眼部判别的疲劳检测系统+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab的异常姿势识别系统+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 隐藏文件展示工具,用来展示被病毒隐藏的文件
- 基于Matlab的图像分割系统+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB指纹门禁GUI设计源码+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab的仪表指数识别系统霍夫曼变换+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB 的霍夫曼变换答题卡识别带GUI界面+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB 疲劳驾驶检测专识别GUI源码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功