pdfmake 0.2.14 → 0.2.15

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/build-vfs.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const fs = require('fs');
2
2
 
3
- const vfsBefore = "this.pdfMake = this.pdfMake || {}; this.pdfMake.vfs = ";
4
- const vfsAfter = ";";
3
+ const vfsBefore = "var vfs = ";
4
+ const vfsAfter = "; var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : this; if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addVirtualFileSystem !== 'undefined') { _global.pdfMake.addVirtualFileSystem(vfs); } if (typeof module !== 'undefined') { module.exports = vfs; }";
5
5
  const sourcePath = process.argv[2];
6
6
  const vfsFilename = process.argv[3] ? process.argv[3] : './build/vfs_fonts.js';
7
7
 
@@ -0,0 +1,52 @@
1
+ import jsdoc from "eslint-plugin-jsdoc";
2
+ import globals from "globals";
3
+ import js from "@eslint/js";
4
+
5
+ export default [
6
+ {
7
+ ignores: ["src/3rd-party/svg-to-pdfkit/*"],
8
+ },
9
+
10
+ js.configs.recommended,
11
+
12
+ {
13
+ plugins: {
14
+ jsdoc,
15
+ },
16
+
17
+ languageOptions: {
18
+ globals: {
19
+ ...globals.browser,
20
+ ...globals.node,
21
+ ...globals.mocha,
22
+ },
23
+
24
+ ecmaVersion: 9,
25
+ sourceType: "module",
26
+ },
27
+
28
+ rules: {
29
+ semi: 2,
30
+ "no-throw-literal": 2,
31
+ "no-prototype-builtins": 0,
32
+ "jsdoc/check-examples": 0,
33
+ "jsdoc/check-param-names": 1,
34
+ "jsdoc/check-tag-names": 1,
35
+ "jsdoc/check-types": 1,
36
+ "jsdoc/no-undefined-types": 1,
37
+ "jsdoc/require-description": 0,
38
+ "jsdoc/require-description-complete-sentence": 0,
39
+ "jsdoc/require-example": 0,
40
+ "jsdoc/require-hyphen-before-param-description": 0,
41
+ "jsdoc/require-param": 1,
42
+ "jsdoc/require-param-description": 0,
43
+ "jsdoc/require-param-name": 1,
44
+ "jsdoc/require-param-type": 1,
45
+ "jsdoc/require-returns": 1,
46
+ "jsdoc/require-returns-check": 1,
47
+ "jsdoc/require-returns-description": 0,
48
+ "jsdoc/require-returns-type": 1,
49
+ "jsdoc/valid-types": 1,
50
+ },
51
+ }
52
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pdfmake",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "description": "Client/server side PDF printing in pure JavaScript",
5
5
  "main": "src/printer.js",
6
6
  "browser": "build/pdfmake.js",
@@ -8,41 +8,43 @@
8
8
  "test": "tests"
9
9
  },
10
10
  "dependencies": {
11
- "@foliojs-fork/linebreak": "^1.1.1",
12
- "@foliojs-fork/pdfkit": "^0.14.0",
11
+ "@foliojs-fork/linebreak": "^1.1.2",
12
+ "@foliojs-fork/pdfkit": "^0.15.1",
13
13
  "iconv-lite": "^0.6.3",
14
- "xmldoc": "^1.1.2"
14
+ "xmldoc": "^1.3.0"
15
15
  },
16
16
  "devDependencies": {
17
- "@babel/cli": "^7.14.5",
18
- "@babel/core": "^7.14.6",
19
- "@babel/plugin-transform-modules-commonjs": "^7.14.5",
20
- "@babel/preset-env": "^7.14.7",
21
- "assert": "^2.0.0",
22
- "babel-loader": "^8.2.2",
17
+ "@babel/cli": "^7.25.9",
18
+ "@babel/core": "^7.26.0",
19
+ "@babel/plugin-transform-modules-commonjs": "^7.25.9",
20
+ "@babel/preset-env": "^7.26.0",
21
+ "@eslint/js": "^9.14.0",
22
+ "assert": "^2.1.0",
23
+ "babel-loader": "^9.2.1",
23
24
  "brfs": "^2.0.2",
24
25
  "browserify-zlib": "^0.2.0",
25
26
  "buffer": "^6.0.3",
26
27
  "core-js": "3.19.0",
27
- "eslint": "^7.29.0",
28
- "eslint-plugin-jsdoc": "^35.4.1",
29
- "expose-loader": "^3.0.0",
28
+ "eslint": "^9.14.0",
29
+ "eslint-plugin-jsdoc": "^50.4.3",
30
+ "expose-loader": "^5.0.0",
30
31
  "file-saver": "^2.0.5",
31
- "mocha": "^9.0.1",
32
+ "globals": "^15.11.0",
33
+ "mocha": "^10.8.2",
32
34
  "npm-run-all": "^4.1.5",
33
35
  "process": "^0.11.10",
34
- "rewire": "^5.0.0",
35
- "shx": "^0.3.3",
36
- "sinon": "^11.1.1",
37
- "source-map-loader": "^4.0.1",
36
+ "rewire": "^7.0.0",
37
+ "shx": "^0.3.4",
38
+ "sinon": "^19.0.2",
39
+ "source-map-loader": "^5.0.0",
38
40
  "stream-browserify": "^3.0.0",
39
41
  "string-replace-webpack-plugin": "^0.1.3",
40
42
  "svg-to-pdfkit": "^0.1.8",
41
- "terser-webpack-plugin": "^5.1.4",
43
+ "terser-webpack-plugin": "^5.3.10",
42
44
  "transform-loader": "^0.2.4",
43
- "util": "^0.12.4",
44
- "webpack": "^5.42.0",
45
- "webpack-cli": "^4.7.2"
45
+ "util": "^0.12.5",
46
+ "webpack": "^5.96.1",
47
+ "webpack-cli": "^5.1.4"
46
48
  },
47
49
  "engines": {
48
50
  "node": ">=18"
@@ -1,9 +1,9 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2019 SVG-to-PDFKit contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 SVG-to-PDFKit contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -2,7 +2,8 @@
2
2
 
3
3
  var isFunction = require('../helpers').isFunction;
4
4
  var isUndefined = require('../helpers').isUndefined;
5
- var isNull = require('../helpers').isNull;
5
+ //var isNull = require('../helpers').isNull;
6
+ var pack = require('../helpers').pack;
6
7
  var FileSaver = require('file-saver');
7
8
  var saveAs = FileSaver.saveAs;
8
9
 
@@ -15,6 +16,10 @@ var defaultClientFonts = {
15
16
  }
16
17
  };
17
18
 
19
+ var globalVfs;
20
+ var globalFonts;
21
+ var globalTableLayouts;
22
+
18
23
  function Document(docDefinition, tableLayouts, fonts, vfs) {
19
24
  this.docDefinition = docDefinition;
20
25
  this.tableLayouts = tableLayouts || null;
@@ -321,9 +326,30 @@ module.exports = {
321
326
  }
322
327
  return new Document(
323
328
  docDefinition,
324
- tableLayouts || global.pdfMake.tableLayouts,
325
- fonts || global.pdfMake.fonts,
326
- vfs || global.pdfMake.vfs
329
+ tableLayouts || globalTableLayouts || global.pdfMake.tableLayouts,
330
+ fonts || globalFonts || global.pdfMake.fonts,
331
+ vfs || globalVfs || global.pdfMake.vfs
327
332
  );
333
+ },
334
+ addVirtualFileSystem: function (vfs) {
335
+ globalVfs = vfs;
336
+ },
337
+ addFonts: function (fonts) {
338
+ globalFonts = pack(globalFonts, fonts);
339
+ },
340
+ setFonts: function (fonts) {
341
+ globalFonts = fonts;
342
+ },
343
+ clearFonts: function () {
344
+ globalFonts = undefined;
345
+ },
346
+ addTableLayouts: function (tableLayouts) {
347
+ globalTableLayouts = pack(globalTableLayouts, tableLayouts);
348
+ },
349
+ setTableLayouts: function (tableLayouts) {
350
+ globalTableLayouts = tableLayouts;
351
+ },
352
+ clearTableLayouts: function () {
353
+ globalTableLayouts = undefined;
328
354
  }
329
355
  };
@@ -26,13 +26,14 @@ function DocumentContext(pageSize, pageMargins) {
26
26
  this.addPage(pageSize);
27
27
  }
28
28
 
29
- DocumentContext.prototype.beginColumnGroup = function (marginXTopParent) {
29
+ DocumentContext.prototype.beginColumnGroup = function (marginXTopParent, bottomByPage = {}) {
30
30
  this.snapshots.push({
31
31
  x: this.x,
32
32
  y: this.y,
33
33
  availableHeight: this.availableHeight,
34
34
  availableWidth: this.availableWidth,
35
35
  page: this.page,
36
+ bottomByPage: bottomByPage ? bottomByPage : {},
36
37
  bottomMost: {
37
38
  x: this.x,
38
39
  y: this.y,
@@ -49,6 +50,16 @@ DocumentContext.prototype.beginColumnGroup = function (marginXTopParent) {
49
50
  }
50
51
  };
51
52
 
53
+ DocumentContext.prototype.updateBottomByPage = function () {
54
+ const lastSnapshot = this.snapshots[this.snapshots.length - 1];
55
+ const lastPage = this.page;
56
+ let previousBottom = -Number.MIN_VALUE;
57
+ if (lastSnapshot.bottomByPage[lastPage]) {
58
+ previousBottom = lastSnapshot.bottomByPage[lastPage];
59
+ }
60
+ lastSnapshot.bottomByPage[lastPage] = Math.max(previousBottom, this.y);
61
+ };
62
+
52
63
  DocumentContext.prototype.resetMarginXTopParent = function () {
53
64
  this.marginXTopParent = null;
54
65
  };
@@ -121,6 +132,7 @@ DocumentContext.prototype.completeColumnGroup = function (height, endingCell) {
121
132
  this.availableHeight -= (y - saved.bottomMost.y);
122
133
  }
123
134
  this.lastColumnWidth = saved.lastColumnWidth;
135
+ return saved.bottomByPage;
124
136
  };
125
137
 
126
138
  DocumentContext.prototype.addMargin = function (left, right) {