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.
没有合适的资源?快使用搜索试试~ 我知道了~
pdf生成插件jspdf
共232个文件
js:101个
html:41个
png:31个
需积分: 26 13 下载量 140 浏览量
2017-03-29
18:15:49
上传
评论 2
收藏 2MB ZIP 举报
温馨提示
pdf生成插件,兼容各种浏览器,样式可以自定义
资源推荐
资源详情
资源评论
收起资源包目录
pdf生成插件jspdf (232个子文件)
Downloadify.as 5KB
Base64.as 5KB
Base64Test.as 2KB
CNAME 10B
bootstrap.css 121KB
bootstrap.min.css 101KB
jquery-ui-1.8.17.custom.css 32KB
bootstrap-responsive.css 21KB
bootstrap-responsive.min.css 16KB
qunit.css 4KB
editor.css 660B
main.css 438B
examples.css 18B
.gitignore 30B
index.htm 173B
images.html 447KB
c__work_jsPDF_jspdf.js.html 351KB
jspdf.js.html 331KB
c__work_jsPDF_tools_jspdf.js.html 148KB
test_context2d.html 59KB
bar_graph_with_text_and_lines.html 52KB
jsPDF.html 42KB
basic.html 17KB
jsPDF-PubSub.html 11KB
index.html 10KB
PubSub.html 10KB
total_mess.html 9KB
FontObject.html 8KB
jsPDFClass.html 7KB
_global_.html 6KB
jsPDF-jsPDF.html 6KB
showcase_supported_html.html 6KB
tables.html 6KB
auto_break.html 4KB
index.html 4KB
pdf.html 4KB
runner.html 4KB
files.html 3KB
test.html 3KB
test_annotation.html 3KB
showcase.html 3KB
test_annotation_2.html 2KB
test_insert_page.html 2KB
pdf2.html 2KB
test_from_html_css_page_breaks.html 2KB
lists.html 2KB
test_from_html.html 2KB
test_from_html_css_page_breaks.html 2KB
downloadify.html 1KB
test_outline.html 1KB
page_break.html 1KB
test.html 1KB
test_min.html 1KB
test_context2d_paths.html 935B
simple.html 829B
jaxer.html 552B
014_addImage.jpeg 8KB
thinking-monkey.jpg 66KB
octocat.jpg 62KB
jpg.jpg 12KB
jspdf.debug.js 619KB
jspdf.min.js 229KB
jquery-ui-1.8.17.custom.min.js 206KB
html2canvas.js 123KB
canvg.js 102KB
jquery-1.7.1.min.js 92KB
jspdf.js 90KB
editor.js 88KB
images_png.js 86KB
deflate.js 68KB
require.js 59KB
bootstrap.js 57KB
context2d.js 55KB
acroform.js 55KB
autoprint.js 50KB
images.js 50KB
qunit.js 41KB
nodeparser.js 36KB
from_html.js 35KB
bootstrap.min.js 31KB
theme-ambiance.js 29KB
standard_fonts_metrics.js 24KB
addimage.js 22KB
StackBlur.js 17KB
zlib.js 17KB
png.js 16KB
cell.js 14KB
png_support.js 14KB
basic.js 10KB
swfobject.js 10KB
pdf_generate_tests.js 10KB
nodecontainer.js 10KB
split_text_to_size.js 9KB
annotations.js 9KB
color.js 8KB
curl-0.5.4.min.js 8KB
rgbcolor.js 7KB
core.js 7KB
outline.js 7KB
canvas.js 6KB
共 232 条
- 1
- 2
- 3
资源评论
HI阡陌
- 粉丝: 10
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功