Skip to content

Commit 203d05a

Browse files
authored
Merge branch 'master' into bugfix/reference-server
2 parents 2003d2e + 91c9d05 commit 203d05a

File tree

388 files changed

+249607
-127929
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

388 files changed

+249607
-127929
lines changed

CNAME

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 50 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,80 @@
11
# jsPDF
22

3-
[![Greenkeeper badge](https://badges.greenkeeper.io/MrRio/jsPDF.svg)](https://greenkeeper.io/)
4-
[![Build Status](https://saucelabs.com/buildstatus/jspdf)](https://saucelabs.com/beta/builds/526e7fda50bd4f97a854bf10f280305d)
5-
[![Code Climate](https://codeclimate.com/repos/57f943855cdc43705e00592f/badges/2665cddeba042dc5191f/gpa.svg)](https://codeclimate.com/repos/57f943855cdc43705e00592f/feed)
6-
[![Test Coverage](https://codeclimate.com/repos/57f943855cdc43705e00592f/badges/2665cddeba042dc5191f/coverage.svg)](https://codeclimate.com/repos/57f943855cdc43705e00592f/coverage)
7-
[![GitHub license](https://img.shields.io/github/license/MrRio/jsPDF.svg)](https://github.com/MrRio/jsPDF/blob/master/LICENSE)
8-
[![Total alerts](https://img.shields.io/lgtm/alerts/g/MrRio/jsPDF.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/MrRio/jsPDF/alerts/)
9-
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/MrRio/jsPDF.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/MrRio/jsPDF/context:javascript)
3+
**Generate PDF files in client-side JavaScript.**
104

5+
This is a fork of [MrRios' jsPDF](https://github.com/MrRio/jsPDF) modified to work with [svg2pdf.js](https://github.com/yWorks/svg2pdf.js), which converts SVG elements to PDF. Since version 2.0.0 this fork is fully compatible to the original version and comes with a large amount of additional features, making this fork also great for standalone usage.
116

7+
Major changes and new features are:
128

13-
**A library to generate PDFs in JavaScript.**
9+
* A global transformation matrix converts between the usual coordinate system (y axis down) and the PDF coordinate system (y axis up) instead of converting every single coordinate.
10+
* PDF FormObjects
11+
* Shading and tiling patterns
12+
* Basic graphics state support
13+
* Full line style support
14+
* ...
1415

15-
You can [catch me on twitter](http://twitter.com/MrRio): [@MrRio](http://twitter.com/MrRio) or head over to [my company's website](http://parall.ax) for consultancy.
16+
#### Version 2.x.x
1617

17-
## [Live Demo](http://raw.githack.com/MrRio/jsPDF/master/) | [Documentation](http://raw.githack.com/MrRio/jsPDF/master/docs/)
18+
With version 2.x.x, this fork is now completely compatible with MrRio's version of jsPDF, which means that all third-party plugins will now also work with this fork! In order to make this possible, we introduced an API-switch between two API modes:
1819

19-
## Creating your first document
20-
21-
The easiest way to get started is to drop the CDN hosted library into your page:
22-
23-
```html
24-
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.debug.js" integrity="sha384-NaWTHo/8YCBYJ59830LTz/P4aQZK1sS0SneOgAvhsIl3zBu8r9RevNg5lHCHAuQ/" crossorigin="anonymous"></script>
25-
```
26-
27-
Integrity-hash generated by https://www.srihash.org/
28-
29-
or can always get latest version via [unpkg](https://unpkg.com/#/)
30-
31-
```html
32-
<script src="https://unpkg.com/jspdf@latest/dist/jspdf.min.js"></script>
33-
```
34-
35-
Using yarn:
36-
37-
```bash
38-
yarn add jspdf
39-
```
40-
41-
Using npm:
42-
43-
```bash
44-
npm install jspdf --save
45-
```
46-
47-
Then you're ready to start making your document:
20+
* In "compat" API mode, jsPDF has the same API as MrRio's version, which means full compatibility with plugins. However, some advanced features like transformation matrices and patterns won't work. This is the default mode.
21+
* In "advanced" API mode, jsPDF has the API you're used from the yWorks-fork 1.x.x versions. This means the availability of all advanced features like patterns, FormObjects and transformation matrices.
4822

23+
You can switch between the two modes by calling
4924
```javascript
50-
// Default export is a4 paper, portrait, using milimeters for units
51-
var doc = new jsPDF()
52-
53-
doc.text('Hello world!', 10, 10)
54-
doc.save('a4.pdf')
55-
```
56-
57-
If you want to change the paper size, orientation, or units, you can do:
58-
59-
```javascript
60-
// Landscape export, 2×4 inches
61-
var doc = new jsPDF({
62-
orientation: 'landscape',
63-
unit: 'in',
64-
format: [4, 2]
25+
doc.advancedAPI(doc => {
26+
// your code
27+
})
28+
// or
29+
doc.compatAPI(doc => {
30+
// your code
6531
})
66-
67-
doc.text('Hello world!', 1, 1)
68-
doc.save('two-by-four.pdf')
69-
7032
```
33+
JsPDF will automatically switch back to the original API mode after the callback has run.
7134

72-
## Use of UTF-8 / TTF:
73-
74-
The 14 standard fonts in PDF are limited to the ASCII-codepage. If you want to use UTF-8 you have to to integrate a custom font, which provides the needed glyphs. jsPDF supports .ttf-files. So if you want to have for example chinese text in your pdf, your font has to have the necessary chinese glyphs. So check if your font supports the wanted glyphs or else it will show a blank space instead of the text.
35+
In addition to this API switch, here is a list of other API-breaking changes:
7536

76-
To add the font to jsPDF use our fontconverter in [/fontconverter/fontconverter.html](https://rawgit.com/MrRio/jsPDF/master/fontconverter/fontconverter.html) . The fontconverter will create a js-file with the content of the provided ttf-file as base64 encoded string and additional code for jsPDF. You just have to add this generated js-File to your project. You are then ready to go to use setFont-method in your code and write your UTF-8 encoded text.
37+
* Some fonts, that don't belong to the 12 standard PDF fonts, had a fallback previously. E.g. "arial" was mapped to "helvetica". Now, these fallbacks don't exist anymore and you have to provide all non-standard fonts yourself.
38+
* The API of the angle/transform parameter `text(...)` method was clarified. See the API-doc for details.
39+
* The `style`, `patternKey` and `patternData` of the path drawing methods are now deprecated and were replaced by a new set of path painting methods. Passing `undefined` as style argument will thus no longer result in a "n" path operator!
40+
* There are four new path construction methods: `moveTo`, `lineTo`, `curveTo` and `close`.
41+
* There are eight new path painting operators, replacing the `style`, `patternKey` and `patternData` arguments: `stroke`, `fill`, `fillEvenOdd`, `fillStroke`, `fillStrokeEvenOdd`, `clip`, `clipEvenOdd` and `discardPath`. The filling operators accept an optional pattern object.
7742

78-
## Angular/Webpack/React/etc. Configuration:
43+
## Creating your first document
44+
```javascript
45+
var doc = new jsPDF();
46+
doc.text(20, 20, 'Hello world.');
47+
doc.save('Test.pdf');
48+
```
7949

80-
If you are using Webpack (including managed cli tools like angular-cli or create-react-app) you can import like this:
50+
There's a live editor example at the top-level `index.html`.
8151

82-
```
83-
import * as jsPDF from 'jspdf'
84-
```
52+
Full API-docs are available through `docs/index.html`.
8553

86-
In some frameworks you have to import jsPDF like this:
54+
## Custom Fonts
55+
jsPDF has built in support for some basic fonts like Helvetica and Times. If you want to add custom fonts you will have
56+
to pack them into a separate JavaScript file using the `fontconverter/fontconverter.html`. Load this file after jsPDF.
8757

88-
```
89-
import jsPDF from 'jspdf';
90-
```
58+
Currently only fonts which are encoded in the TrueType format (*.ttf) are supported.
9159

92-
You can add jsPDF to your meteor-project as follows:
60+
Note that the `jspdf-makeFonts` tool is deprecated.
9361

62+
## Building
63+
Build the library with
9464
```
95-
meteor add jspdf:core
65+
npm install
66+
npm run build
9667
```
68+
This will fetch all dependencies and then compile the `dist` files. To see the examples locally you can start a web server with `npm start` and go to `localhost:8000`.
9769

98-
## Support
99-
100-
Please check if your question is already handled at Stackoverflow <https://stackoverflow.com/questions/tagged/jspdf>.
101-
Feel free to ask a question there with the tag `jspdf`.
102-
103-
Feature requests, bug reports etc. are very welcome as issues. Note that bug reports should follow these guidelines:
104-
105-
* A bug should be reported as an [mcve](https://stackoverflow.com/help/mcve)
106-
* Make sure code is properly indented and [formatted](https://help.github.com/articles/basic-writing-and-formatting-syntax/#quoting-code) (Use ``` around code blocks)
107-
* Provide a runnable example.
108-
* Try to make sure and show in your issue that the issue is actually related to jspdf and not your framework of choice your setup.
109-
110-
## Contributing
111-
112-
Build the library with `npm run build`. This will fetch all dependencies and then compile the `dist` files. To see the examples locally you can start a web server with `npm start` and go to `localhost:8000`.
113-
114-
Alternatively, you can build jsPDF using these commands in a readily configured online workspace:
11570

116-
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io#https://github.com/MrRio/jsPDF)
71+
## License
11772

118-
## Credits
119-
- Big thanks to Daniel Dotsenko from [Willow Systems Corporation](https://github.com/willowsystems) for making huge contributions to the codebase.
120-
- Thanks to Ajaxian.com for [featuring us back in 2009](http://ajaxian.com/archives/dynamically-generic-pdfs-with-javascript).
121-
- Our special thanks to GH Lee ([sphilee](https://github.com/sphilee)) for programming the ttf-file-support and providing a large and long sought after feature
122-
- Everyone else that's contributed patches or bug reports. You rock.
73+
(MIT License)
12374

124-
## License (MIT)
125-
Copyright (c) 2010-2017 James Hall, https://github.com/MrRio/jsPDF
75+
Copyright
76+
* (c) 2010-2016 James Hall, https://github.com/MrRio/jsPDF
77+
* (c) 2015-2018 yWorks GmbH, http://www.yworks.com/
12678

12779
Permission is hereby granted, free of charge, to any person obtaining
12880
a copy of this software and associated documentation files (the

bower.json

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"name": "jspdf",
3-
"homepage": "https://github.com/mrrio/jspdf",
2+
"name": "jspdf-yworks",
3+
"version": "2.1.1",
4+
"homepage": "https://github.com/yWorks/jsPDF",
45
"description": "PDF Document creation from JavaScript",
56
"main": [
67
"dist/jspdf.debug.js",
@@ -16,43 +17,54 @@
1617
"pdf"
1718
],
1819
"dependencies": {
19-
"file-saver": "1.3.8",
20-
"html2canvas": "1.0.0-alpha.12",
21-
"promise-polyfill": "8.1.0",
22-
"stackblur-canvas": "1.4.1"
20+
"atob": "^2.1.2",
21+
"btoa": "^1.2.1",
22+
"canvg": "1.5.3",
23+
"es6-promise": "^4.2.6",
24+
"file-saver": "2.0.1",
25+
"html2canvas": "^1.0.0-rc.1",
26+
"omggif": "1.0.9",
27+
"stackblur-canvas": "2.2.0"
2328
},
2429
"devDependencies": {
25-
"@babel/core": "^7.0.0",
26-
"@babel/plugin-external-helpers": "7.0.0",
27-
"@babel/preset-env": "^7.0.0",
30+
"@babel/core": "^7.4.3",
31+
"@babel/plugin-external-helpers": "7.2.0",
32+
"@babel/preset-env": "^7.4.3",
33+
"acorn": "^6.1.1",
2834
"babel-plugin-rewire-exports": "1.0.1",
2935
"codeclimate-test-reporter": "0.5.1",
30-
"diff": "3.5.0",
31-
"docdash": "1.0.0",
32-
"folder-delete": "1.0.3",
36+
"diff": "4.0.1",
37+
"docdash": "1.1.0",
38+
"eslint": "^5.16.0",
39+
"folder-delete": "1.0.4",
3340
"gulp-babel": "^8.0.0",
34-
"jasmine-core": "3.3.0",
35-
"jasmine-expect": "^3.8.4",
36-
"jasmine-matchers": "^0.2.3",
37-
"js-yaml": "3.12.0",
38-
"jsdoc": "3.5.5",
39-
"karma": "3.1.1",
40-
"karma-babel-preprocessor": "^8.0.0-beta.0",
41+
"inquirer": "^6.2.2",
42+
"jasmine": "^3.4.0",
43+
"jasmine-core": "3.4.0",
44+
"jasmine-expect": "^4.0.1",
45+
"js-yaml": "3.13.1",
46+
"jsdoc": "3.6.0",
47+
"karma": "4.0.1",
48+
"karma-babel-preprocessor": "^8.0.0",
4149
"karma-chrome-launcher": "2.2.0",
4250
"karma-coverage": "1.1.2",
4351
"karma-firefox-launcher": "1.1.0",
4452
"karma-ie-launcher": "1.0.0",
45-
"karma-jasmine": "^1.1.2",
46-
"karma-jasmine-matchers": "^3.8.3",
53+
"karma-jasmine": "^2.0.1",
54+
"karma-jasmine-matchers": "^4.0.1",
4755
"karma-mocha-reporter": "2.2.5",
48-
"karma-sauce-launcher": "1.2.0",
56+
"karma-sauce-launcher": "2.0.2",
4957
"karma-verbose-reporter": "0.0.6",
50-
"local-web-server": "2.6.0",
58+
"local-web-server": "2.6.1",
5159
"markdown": "0.5.0",
52-
"rollup": "0.66.6",
53-
"rollup-plugin-babel": "4.0.3",
54-
"rollup-plugin-node-resolve": "3.4.0",
55-
"uglify-js": "3.4.9"
60+
"prettier": "^1.13.7",
61+
"promise-polyfill": "8.1.1",
62+
"rollup": "1.12.1",
63+
"rollup-plugin-babel": "4.3.2",
64+
"rollup-plugin-buble": "^0.19.6",
65+
"rollup-plugin-node-resolve": "4.2.3",
66+
"rollup-plugin-sizes": "^0.5.1",
67+
"uglify-js": "3.5.8"
5668
},
5769
"license": "MIT",
5870
"ignore": [

build.browser.conf.js

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
import './src/license.js';
2-
import './src/libs/polyfill.js';
3-
import './src/jspdf.js';
4-
5-
import './src/modules/acroform';
6-
import './src/modules/addimage';
7-
import './src/modules/annotations';
8-
import './src/modules/arabic';
9-
import './src/modules/autoprint';
10-
import './src/modules/canvas';
11-
import './src/modules/cell';
12-
import './src/modules/context2d';
13-
import './src/modules/filters';
14-
import './src/modules/fileloading';
15-
import './src/modules/html';
16-
import './src/modules/javascript';
17-
import './src/modules/outline';
18-
import './src/modules/jpeg_support';
19-
import './src/modules/png_support';
20-
import './src/modules/gif_support';
21-
import './src/modules/bmp_support';
22-
import './src/modules/webp_support';
23-
import './src/modules/setlanguage';
24-
import './src/modules/split_text_to_size';
25-
import './src/modules/standard_fonts_metrics';
26-
import './src/modules/ttfsupport';
27-
import './src/modules/svg';
28-
import './src/modules/total_pages';
29-
import './src/modules/viewerpreferences';
30-
import './src/modules/xmp_metadata';
31-
import './src/modules/utf8';
32-
import './src/modules/vfs';
33-
34-
import './src/deprecated/addhtml.js';
35-
import './src/deprecated/from_html.js';
36-
import './src/deprecated/html2pdf.js';
37-
38-
import './src/libs/Blob.js';
39-
import './src/libs/omggif.js';
40-
import './src/libs/adler32cs.js';
41-
import './src/libs/bidiEngine.js';
42-
import './src/libs/JPEGEncoder.js';
43-
import './src/libs/BMPDecoder.js';
44-
import './src/libs/WebPDecoder.js';
45-
import './src/libs/Deflater.js';
46-
import './src/libs/rgbcolor.js';
47-
import './src/libs/ttffont.js';
48-
import './src/libs/png.js';
49-
import './src/libs/zlib.js';
50-
import './src/libs/FileSaver.js';
1+
import './src/license.js';
2+
import './src/libs/polyfill.js';
3+
import './src/jspdf.js';
4+
5+
import './src/modules/acroform';
6+
import './src/modules/addimage';
7+
import './src/modules/annotations';
8+
import './src/modules/arabic';
9+
import './src/modules/autoprint';
10+
import './src/modules/canvas';
11+
import './src/modules/cell';
12+
import './src/modules/context2d';
13+
import './src/modules/filters';
14+
import './src/modules/fileloading';
15+
import './src/modules/html';
16+
import './src/modules/javascript';
17+
import './src/modules/outline';
18+
import './src/modules/jpeg_support';
19+
import './src/modules/png_support';
20+
import './src/modules/gif_support';
21+
import './src/modules/bmp_support';
22+
import './src/modules/webp_support';
23+
import './src/modules/setlanguage';
24+
import './src/modules/split_text_to_size';
25+
import './src/modules/standard_fonts_metrics';
26+
import './src/modules/ttfsupport';
27+
import './src/modules/svg';
28+
import './src/modules/total_pages';
29+
import './src/modules/viewerpreferences';
30+
import './src/modules/xmp_metadata';
31+
import './src/modules/utf8';
32+
import './src/modules/vfs';
33+
34+
import './src/deprecated/addhtml.js';
35+
import './src/deprecated/from_html.js';
36+
import './src/deprecated/html2pdf.js';
37+
38+
import './src/libs/Blob.js';
39+
import './src/libs/omggif.js';
40+
import './src/libs/adler32cs.js';
41+
import './src/libs/bidiEngine.js';
42+
import './src/libs/JPEGEncoder.js';
43+
import './src/libs/BMPDecoder.js';
44+
import './src/libs/WebPDecoder.js';
45+
import './src/libs/Deflater.js';
46+
import './src/libs/rgbcolor.js';
47+
import './src/libs/ttffont.js';
48+
import './src/libs/png.js';
49+
import './src/libs/zlib.js';
50+
import './src/libs/FileSaver.js';

0 commit comments

Comments
 (0)