pdfmake 0.1.66 → 0.1.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/modules.xml +8 -0
- package/.idea/pdfmake.iml +11 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +4 -1
- package/build/pdfmake.js +6359 -4062
- package/build/pdfmake.js.map +1 -1
- package/build/pdfmake.min.js +2 -37
- package/build/pdfmake.min.js.map +1 -1
- package/package.json +74 -73
- package/src/browser-extensions/URLBrowserResolver.js +63 -61
- package/src/browser-extensions/pdfMake.js +8 -0
- package/src/browser-extensions/virtual-fs.js +6 -0
- package/src/imageMeasure.js +6 -0
- package/src/printer.js +685 -651
- package/src/styleContextStack.js +3 -1
- package/src/svgMeasure.js +45 -81
- package/src/textTools.js +9 -0
- package/webpack.config.js +23 -12
package/package.json
CHANGED
|
@@ -1,73 +1,74 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "pdfmake",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Client/server side PDF printing in pure JavaScript",
|
|
5
|
-
"main": "src/printer.js",
|
|
6
|
-
"browser": "build/pdfmake.js",
|
|
7
|
-
"directories": {
|
|
8
|
-
"test": "tests"
|
|
9
|
-
},
|
|
10
|
-
"dependencies": {
|
|
11
|
-
"iconv-lite": "^0.6.
|
|
12
|
-
"linebreak": "^1.0.2",
|
|
13
|
-
"pdfkit": "^0.11.0",
|
|
14
|
-
"svg-to-pdfkit": "^0.1.8"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"@babel/
|
|
19
|
-
"@babel/
|
|
20
|
-
"babel-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"gulp
|
|
29
|
-
"gulp-
|
|
30
|
-
"gulp-
|
|
31
|
-
"gulp-
|
|
32
|
-
"mocha": "^
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "pdfmake",
|
|
3
|
+
"version": "0.1.70",
|
|
4
|
+
"description": "Client/server side PDF printing in pure JavaScript",
|
|
5
|
+
"main": "src/printer.js",
|
|
6
|
+
"browser": "build/pdfmake.js",
|
|
7
|
+
"directories": {
|
|
8
|
+
"test": "tests"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"iconv-lite": "^0.6.2",
|
|
12
|
+
"linebreak": "^1.0.2",
|
|
13
|
+
"pdfkit": "^0.11.0",
|
|
14
|
+
"svg-to-pdfkit": "^0.1.8",
|
|
15
|
+
"xmldoc": "^1.1.2"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@babel/core": "^7.12.10",
|
|
19
|
+
"@babel/plugin-transform-modules-commonjs": "^7.12.1",
|
|
20
|
+
"@babel/preset-env": "^7.12.11",
|
|
21
|
+
"babel-loader": "^8.2.2",
|
|
22
|
+
"brfs": "^2.0.2",
|
|
23
|
+
"core-js": "^3.8.1",
|
|
24
|
+
"eslint-plugin-jsdoc": "^30.7.9",
|
|
25
|
+
"expose-loader": "^1.0.3",
|
|
26
|
+
"fancy-log": "^1.3.3",
|
|
27
|
+
"file-saver": "^2.0.5",
|
|
28
|
+
"gulp": "^4.0.2",
|
|
29
|
+
"gulp-each": "^0.5.0",
|
|
30
|
+
"gulp-eslint": "^6.0.0",
|
|
31
|
+
"gulp-file-contents-to-json": "^0.2.2",
|
|
32
|
+
"gulp-spawn-mocha": "^6.0.0",
|
|
33
|
+
"mocha": "7.2.0",
|
|
34
|
+
"rewire": "^5.0.0",
|
|
35
|
+
"sinon": "^9.2.2",
|
|
36
|
+
"string-replace-webpack-plugin": "^0.1.3",
|
|
37
|
+
"terser-webpack-plugin": "2.3.8",
|
|
38
|
+
"transform-loader": "^0.2.4",
|
|
39
|
+
"webpack": "^4.44.2"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=8"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "gulp build",
|
|
46
|
+
"test": "gulp",
|
|
47
|
+
"playground": "node dev-playground/server.js"
|
|
48
|
+
},
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "git://github.com/bpampuch/pdfmake.git"
|
|
52
|
+
},
|
|
53
|
+
"keywords": [
|
|
54
|
+
"pdf",
|
|
55
|
+
"javascript",
|
|
56
|
+
"printing",
|
|
57
|
+
"layout"
|
|
58
|
+
],
|
|
59
|
+
"author": "Bartek Pampuch <bartosz.pampuch@gmail.com>",
|
|
60
|
+
"license": "MIT",
|
|
61
|
+
"bugs": {
|
|
62
|
+
"url": "https://github.com/bpampuch/pdfmake/issues"
|
|
63
|
+
},
|
|
64
|
+
"homepage": "http://pdfmake.org",
|
|
65
|
+
"config": {
|
|
66
|
+
"blanket": {
|
|
67
|
+
"pattern": "src",
|
|
68
|
+
"data-cover-never": [
|
|
69
|
+
"node_modules",
|
|
70
|
+
"tests"
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -1,86 +1,88 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// Internet Explorer polyfills
|
|
4
|
-
|
|
4
|
+
if (typeof window !== 'undefined' && !window.Promise) {
|
|
5
|
+
require('core-js/features/promise');
|
|
6
|
+
}
|
|
5
7
|
require('core-js/es/object/values');
|
|
6
8
|
|
|
7
9
|
var fetchUrl = function (url) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
return new Promise(function (resolve, reject) {
|
|
11
|
+
var xhr = new XMLHttpRequest();
|
|
12
|
+
xhr.open('GET', url, true);
|
|
13
|
+
xhr.responseType = 'arraybuffer';
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
xhr.onreadystatechange = function () {
|
|
16
|
+
if (xhr.readyState !== 4) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
var ok = xhr.status >= 200 && xhr.status < 300;
|
|
21
|
+
if (!ok) {
|
|
22
|
+
setTimeout(function () {
|
|
23
|
+
reject(new TypeError('Failed to fetch (url: "' + url + '")'));
|
|
24
|
+
}, 0);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
xhr.onload = function () {
|
|
29
|
+
var ok = xhr.status >= 200 && xhr.status < 300;
|
|
30
|
+
if (ok) {
|
|
31
|
+
resolve(xhr.response);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
xhr.onerror = function () {
|
|
36
|
+
setTimeout(function () {
|
|
37
|
+
reject(new TypeError('Network request failed (url: "' + url + '")'));
|
|
38
|
+
}, 0);
|
|
39
|
+
};
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
xhr.ontimeout = function () {
|
|
42
|
+
setTimeout(function () {
|
|
43
|
+
reject(new TypeError('Network request failed (url: "' + url + '")'));
|
|
44
|
+
}, 0);
|
|
45
|
+
};
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
xhr.send();
|
|
48
|
+
});
|
|
47
49
|
};
|
|
48
50
|
|
|
49
51
|
function URLBrowserResolver(fs) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
this.fs = fs;
|
|
53
|
+
this.resolving = {};
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
URLBrowserResolver.prototype.resolve = function (url) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
57
|
+
if (!this.resolving[url]) {
|
|
58
|
+
var _this = this;
|
|
59
|
+
this.resolving[url] = new Promise(function (resolve, reject) {
|
|
60
|
+
if (url.toLowerCase().indexOf('https://') === 0 || url.toLowerCase().indexOf('http://') === 0) {
|
|
61
|
+
fetchUrl(url).then(function (buffer) {
|
|
62
|
+
_this.fs.writeFileSync(url, buffer);
|
|
63
|
+
resolve();
|
|
64
|
+
}, function (result) {
|
|
65
|
+
reject(result);
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
// cannot be resolved
|
|
69
|
+
resolve();
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
71
73
|
|
|
72
|
-
|
|
74
|
+
return this.resolving[url];
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
URLBrowserResolver.prototype.resolved = function () {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
var _this = this;
|
|
79
|
+
return new Promise(function (resolve, reject) {
|
|
80
|
+
Promise.all(Object.values(_this.resolving)).then(function () {
|
|
81
|
+
resolve();
|
|
82
|
+
}, function (result) {
|
|
83
|
+
reject(result);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
module.exports = URLBrowserResolver;
|
|
@@ -67,6 +67,14 @@ Document.prototype._createDoc = function (options, cb) {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
if (this.docDefinition.images) {
|
|
71
|
+
for (var image in this.docDefinition.images) {
|
|
72
|
+
if (this.docDefinition.images.hasOwnProperty(image)) {
|
|
73
|
+
urlResolver.resolve(this.docDefinition.images[image]);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
70
78
|
var _this = this;
|
|
71
79
|
|
|
72
80
|
urlResolver.resolved().then(function () {
|
|
@@ -5,6 +5,12 @@ function VirtualFileSystem() {
|
|
|
5
5
|
this.dataSystem = {};
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
VirtualFileSystem.prototype.existsSync = function (filename) {
|
|
9
|
+
filename = fixFilename(filename);
|
|
10
|
+
return typeof this.fileSystem[filename] !== 'undefined'
|
|
11
|
+
|| typeof this.dataSystem[filename] !== 'undefined';
|
|
12
|
+
}
|
|
13
|
+
|
|
8
14
|
VirtualFileSystem.prototype.readFileSync = function (filename, options) {
|
|
9
15
|
filename = fixFilename(filename);
|
|
10
16
|
|
package/src/imageMeasure.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
|
|
3
5
|
function ImageMeasure(pdfKitDoc, imageDictionary) {
|
|
4
6
|
this.pdfKitDoc = pdfKitDoc;
|
|
5
7
|
this.imageDictionary = imageDictionary || {};
|
|
@@ -33,6 +35,10 @@ ImageMeasure.prototype.measureImage = function (src) {
|
|
|
33
35
|
return src;
|
|
34
36
|
}
|
|
35
37
|
|
|
38
|
+
if (fs.existsSync(img)) {
|
|
39
|
+
return fs.readFileSync(img);
|
|
40
|
+
}
|
|
41
|
+
|
|
36
42
|
var index = img.indexOf('base64,');
|
|
37
43
|
if (index < 0) {
|
|
38
44
|
return that.imageDictionary[src];
|