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/package.json CHANGED
@@ -1,73 +1,74 @@
1
- {
2
- "name": "pdfmake",
3
- "version": "0.1.66",
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.0",
12
- "linebreak": "^1.0.2",
13
- "pdfkit": "^0.11.0",
14
- "svg-to-pdfkit": "^0.1.8"
15
- },
16
- "devDependencies": {
17
- "@babel/core": "^7.10.3",
18
- "@babel/plugin-transform-modules-commonjs": "^7.10.1",
19
- "@babel/preset-env": "^7.10.3",
20
- "babel-loader": "^8.1.0",
21
- "brfs": "^2.0.2",
22
- "core-js": "^3.6.5",
23
- "eslint-plugin-jsdoc": "^27.1.2",
24
- "expose-loader": "^1.0.0",
25
- "fancy-log": "^1.3.3",
26
- "file-saver": "^2.0.2",
27
- "gulp": "^4.0.2",
28
- "gulp-each": "^0.5.0",
29
- "gulp-eslint": "^6.0.0",
30
- "gulp-file-contents-to-json": "^0.2.2",
31
- "gulp-spawn-mocha": "^6.0.0",
32
- "mocha": "^7.2.0",
33
- "rewire": "^5.0.0",
34
- "sinon": "^9.0.2",
35
- "string-replace-webpack-plugin": "^0.1.3",
36
- "transform-loader": "^0.2.4",
37
- "uglifyjs-webpack-plugin": "^2.2.0",
38
- "webpack": "^4.43.0"
39
- },
40
- "engines": {
41
- "node": ">=8"
42
- },
43
- "scripts": {
44
- "build": "gulp build",
45
- "test": "gulp",
46
- "playground": "node dev-playground/server.js"
47
- },
48
- "repository": {
49
- "type": "git",
50
- "url": "git://github.com/bpampuch/pdfmake.git"
51
- },
52
- "keywords": [
53
- "pdf",
54
- "javascript",
55
- "printing",
56
- "layout"
57
- ],
58
- "author": "Bartek Pampuch <bartosz.pampuch@gmail.com>",
59
- "license": "MIT",
60
- "bugs": {
61
- "url": "https://github.com/bpampuch/pdfmake/issues"
62
- },
63
- "homepage": "http://pdfmake.org",
64
- "config": {
65
- "blanket": {
66
- "pattern": "src",
67
- "data-cover-never": [
68
- "node_modules",
69
- "tests"
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
- require('core-js/features/promise');
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
- return new Promise(function (resolve, reject) {
9
- var xhr = new XMLHttpRequest();
10
- xhr.open('GET', url, true);
11
- xhr.responseType = 'arraybuffer';
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
- xhr.onreadystatechange = function () {
14
- if (xhr.readyState !== 4) {
15
- return;
16
- }
15
+ xhr.onreadystatechange = function () {
16
+ if (xhr.readyState !== 4) {
17
+ return;
18
+ }
17
19
 
18
- var ok = xhr.status >= 200 && xhr.status < 300;
19
- if (!ok) {
20
- setTimeout(function () {
21
- reject(new TypeError('Failed to fetch (url: "' + url + '")'));
22
- }, 0);
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
- xhr.onload = function () {
27
- var ok = xhr.status >= 200 && xhr.status < 300;
28
- if (ok) {
29
- resolve(xhr.response);
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
- xhr.onerror = function () {
34
- setTimeout(function () {
35
- reject(new TypeError('Network request failed (url: "' + url + '")'));
36
- }, 0);
37
- };
35
+ xhr.onerror = function () {
36
+ setTimeout(function () {
37
+ reject(new TypeError('Network request failed (url: "' + url + '")'));
38
+ }, 0);
39
+ };
38
40
 
39
- xhr.ontimeout = function () {
40
- setTimeout(function () {
41
- reject(new TypeError('Network request failed (url: "' + url + '")'));
42
- }, 0);
43
- };
41
+ xhr.ontimeout = function () {
42
+ setTimeout(function () {
43
+ reject(new TypeError('Network request failed (url: "' + url + '")'));
44
+ }, 0);
45
+ };
44
46
 
45
- xhr.send();
46
- });
47
+ xhr.send();
48
+ });
47
49
  };
48
50
 
49
51
  function URLBrowserResolver(fs) {
50
- this.fs = fs;
51
- this.resolving = {};
52
+ this.fs = fs;
53
+ this.resolving = {};
52
54
  }
53
55
 
54
56
  URLBrowserResolver.prototype.resolve = function (url) {
55
- if (!this.resolving[url]) {
56
- var _this = this;
57
- this.resolving[url] = new Promise(function (resolve, reject) {
58
- if (url.toLowerCase().indexOf('https://') === 0 || url.toLowerCase().indexOf('http://') === 0) {
59
- fetchUrl(url).then(function (buffer) {
60
- _this.fs.writeFileSync(url, buffer);
61
- resolve();
62
- }, function (result) {
63
- reject(result);
64
- });
65
- } else {
66
- // cannot be resolved
67
- resolve();
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
- return this.resolving[url];
74
+ return this.resolving[url];
73
75
  }
74
76
 
75
77
  URLBrowserResolver.prototype.resolved = function () {
76
- var _this = this;
77
- return new Promise(function (resolve, reject) {
78
- Promise.all(Object.values(_this.resolving)).then(function () {
79
- resolve();
80
- }, function (result) {
81
- reject(result);
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
 
@@ -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];