Skip to content

Commit 1bbe31b

Browse files
committed
Merge branch 'release/v0.8.1'
2 parents 951bad5 + a34ca2f commit 1bbe31b

File tree

12 files changed

+85
-31
lines changed

12 files changed

+85
-31
lines changed

.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
.archive/
3+
.devel/
4+
dist/*.bundle*.js
5+
dist/**/*.min.js

README.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,35 @@ html2pdf converts any webpage or element into a printable PDF entirely client-si
44

55
## Getting started
66

7-
There are two ways to install html2pdf:
7+
### HTML
88

9-
1. **NPM:** Use `npm install --save html2pdf.js` to add html2pdf and its dependencies to your project.
10-
2. **HTML:** Download `dist/html2pdf.bundle.min.js` to your project folder and include it in your HTML with: `<script src="html2pdf.bundle.min.js"></script>`.
9+
The simplest way to use html2pdf is to download `dist/html2pdf.bundle.min.js` to your project folder and include it in your HTML with:
1110

12-
Once installed, html2pdf is ready to use. This command will generate a PDF of `#element-to-print` and prompt the user to save the result:
11+
```html
12+
<script src="html2pdf.bundle.min.js"></script>
13+
```
14+
15+
*[Click here](#dependencies) for more information about using the unbundled version `dist/html2canvas.min.js`.*
16+
17+
### NPM
18+
19+
Install html2pdf and its dependencies using NPM with `npm install --save html2pdf.js` (make sure to include `.js` in the package name).
20+
21+
*Note: You can use NPM to create your project, but html2pdf **will not run in Node.js**, it must be run in a browser.*
22+
23+
### Bower
24+
25+
Install html2pdf and its dependencies using Bower with `bower install --save html2pdf.js` (make sure to include `.js` in the package name).
26+
27+
## Usage
28+
29+
Once installed, html2pdf is ready to use. The following command will generate a PDF of `#element-to-print` and prompt the user to save the result:
1330

1431
```js
1532
var element = document.getElementById('element-to-print');
1633
html2pdf(element);
1734
```
1835

19-
*Note: html2pdf **will not run in Node.js**, it must be run in a browser.*
20-
21-
*[Click here](#dependencies) for more information about using the unbundled version `dist/html2canvas.min.js`.*
22-
2336
## Options
2437

2538
html2pdf can be configured using an optional `opt` parameter:
@@ -71,11 +84,12 @@ These options are limited to the available settings for [HTMLCanvasElement.toDat
7184

7285
## Dependencies
7386

74-
html2pdf depends on the external packages [html2canvas](https://github.com/niklasvh/html2canvas) and [jsPDF](https://github.com/MrRio/jsPDF). These dependencies are automatically loaded when using NPM or the bundled package.
87+
html2pdf depends on the external packages [html2canvas](https://github.com/niklasvh/html2canvas), [jsPDF](https://github.com/MrRio/jsPDF), and [es6-promise](https://github.com/stefanpenner/es6-promise). These dependencies are automatically loaded when using NPM or the bundled package.
7588

7689
If using the unbundled `dist/html2pdf.min.js` (or its un-minified version), you must also include each dependency. Order is important, otherwise html2canvas will be overridden by jsPDF's own internal implementation:
7790

7891
```html
92+
<script src="es6-promise.auto.min.js"></script>
7993
<script src="jspdf.min.js"></script>
8094
<script src="html2canvas.min.js"></script>
8195
<script src="html2pdf.min.js"></script>

bower.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "html2pdf.js",
3+
"description": "Client-side HTML-to-PDF rendering using pure JS",
4+
"main": "dist/html2pdf.bundle.js",
5+
"moduleType": [
6+
"amd",
7+
"globals",
8+
"node"
9+
],
10+
"authors": [
11+
"Erik Koopmans <[email protected]>"
12+
],
13+
"license": "MIT",
14+
"keywords": [
15+
"javascript",
16+
"pdf-generation",
17+
"html",
18+
"client-side",
19+
"canvas"
20+
],
21+
"homepage": "https://github.com/eKoopmans/html2pdf",
22+
"ignore": [
23+
"node_modules/",
24+
"bower_components/",
25+
".archive/",
26+
".devel/"
27+
]
28+
}

dist/html2pdf.bundle.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* html2pdf v0.8.0
2+
* html2pdf.js v0.8.1
33
* Copyright (c) 2017 Erik Koopmans
44
* Released under the MIT License.
55
*/
@@ -5065,7 +5065,8 @@ jspdf_min.getPageSize = function (orientation, unit, format) {
50655065

50665066
// Determine the type of a variable/object.
50675067
var objType = function objType(obj) {
5068-
if (typeof obj === 'undefined') return 'undefined';else if (typeof obj === 'string' || obj instanceof String) return 'string';else if (typeof obj === 'number' || obj instanceof Number) return 'number';else if (!!obj && obj.constructor === Array) return 'array';else if (obj && obj.nodeType === 1) return 'element';else if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object') return 'object';else return 'unknown';
5068+
var type = typeof obj === 'undefined' ? 'undefined' : _typeof(obj);
5069+
if (type === 'undefined') return 'undefined';else if (type === 'string' || obj instanceof String) return 'string';else if (type === 'number' || obj instanceof Number) return 'number';else if (type === 'function' || obj instanceof Function) return 'function';else if (!!obj && obj.constructor === Array) return 'array';else if (obj && obj.nodeType === 1) return 'element';else if (type === 'object') return 'object';else return 'unknown';
50695070
};
50705071

50715072
// Create an HTML element with optional className, innerHTML, and style.

dist/html2pdf.bundle.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/html2pdf.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* html2pdf v0.8.0
2+
* html2pdf.js v0.8.1
33
* Copyright (c) 2017 Erik Koopmans
44
* Released under the MIT License.
55
*/
@@ -124,7 +124,8 @@ jsPDF.getPageSize = function (orientation, unit, format) {
124124

125125
// Determine the type of a variable/object.
126126
var objType = function objType(obj) {
127-
if (typeof obj === 'undefined') return 'undefined';else if (typeof obj === 'string' || obj instanceof String) return 'string';else if (typeof obj === 'number' || obj instanceof Number) return 'number';else if (!!obj && obj.constructor === Array) return 'array';else if (obj && obj.nodeType === 1) return 'element';else if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object') return 'object';else return 'unknown';
127+
var type = typeof obj === 'undefined' ? 'undefined' : _typeof(obj);
128+
if (type === 'undefined') return 'undefined';else if (type === 'string' || obj instanceof String) return 'string';else if (type === 'number' || obj instanceof Number) return 'number';else if (type === 'function' || obj instanceof Function) return 'function';else if (!!obj && obj.constructor === Array) return 'array';else if (obj && obj.nodeType === 1) return 'element';else if (type === 'object') return 'object';else return 'unknown';
128129
};
129130

130131
// Create an HTML element with optional className, innerHTML, and style.

dist/html2pdf.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/include/html2pdf.es.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* html2pdf v0.8.0
2+
* html2pdf.js v0.8.1
33
* Copyright (c) 2017 Erik Koopmans
44
* Released under the MIT License.
55
*/
@@ -119,7 +119,8 @@ jsPDF.getPageSize = function (orientation, unit, format) {
119119

120120
// Determine the type of a variable/object.
121121
var objType = function objType(obj) {
122-
if (typeof obj === 'undefined') return 'undefined';else if (typeof obj === 'string' || obj instanceof String) return 'string';else if (typeof obj === 'number' || obj instanceof Number) return 'number';else if (!!obj && obj.constructor === Array) return 'array';else if (obj && obj.nodeType === 1) return 'element';else if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object') return 'object';else return 'unknown';
122+
var type = typeof obj === 'undefined' ? 'undefined' : _typeof(obj);
123+
if (type === 'undefined') return 'undefined';else if (type === 'string' || obj instanceof String) return 'string';else if (type === 'number' || obj instanceof Number) return 'number';else if (type === 'function' || obj instanceof Function) return 'function';else if (!!obj && obj.constructor === Array) return 'array';else if (obj && obj.nodeType === 1) return 'element';else if (type === 'object') return 'object';else return 'unknown';
123124
};
124125

125126
// Create an HTML element with optional className, innerHTML, and style.

0 commit comments

Comments
 (0)