pdfmake 0.2.18 → 0.2.20

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,6 +1,6 @@
1
1
  {
2
2
  "name": "pdfmake",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "description": "Client/server side PDF printing in pure JavaScript",
5
5
  "main": "src/printer.js",
6
6
  "browser": "build/pdfmake.js",
@@ -11,39 +11,39 @@
11
11
  "@foliojs-fork/linebreak": "^1.1.2",
12
12
  "@foliojs-fork/pdfkit": "^0.15.3",
13
13
  "iconv-lite": "^0.6.3",
14
- "xmldoc": "^1.3.0"
14
+ "xmldoc": "^2.0.1"
15
15
  },
16
16
  "devDependencies": {
17
- "@babel/cli": "^7.26.4",
18
- "@babel/core": "^7.26.0",
19
- "@babel/plugin-transform-modules-commonjs": "^7.26.3",
20
- "@babel/preset-env": "^7.26.0",
21
- "@eslint/js": "^9.17.0",
17
+ "@babel/cli": "^7.27.2",
18
+ "@babel/core": "^7.27.1",
19
+ "@babel/plugin-transform-modules-commonjs": "^7.27.1",
20
+ "@babel/preset-env": "^7.27.2",
21
+ "@eslint/js": "^9.26.0",
22
22
  "assert": "^2.1.0",
23
- "babel-loader": "^9.2.1",
23
+ "babel-loader": "^10.0.0",
24
24
  "brfs": "^2.0.2",
25
25
  "browserify-zlib": "^0.2.0",
26
26
  "buffer": "^6.0.3",
27
27
  "core-js": "3.19.0",
28
- "eslint": "^9.17.0",
29
- "eslint-plugin-jsdoc": "^50.6.1",
30
- "expose-loader": "^5.0.0",
28
+ "eslint": "^9.26.0",
29
+ "eslint-plugin-jsdoc": "^50.6.11",
30
+ "expose-loader": "^5.0.1",
31
31
  "file-saver": "^2.0.5",
32
- "globals": "^15.14.0",
33
- "mocha": "^11.0.1",
32
+ "globals": "^16.1.0",
33
+ "mocha": "^11.2.2",
34
34
  "npm-run-all": "^4.1.5",
35
35
  "process": "^0.11.10",
36
36
  "rewire": "^7.0.0",
37
- "shx": "^0.3.4",
38
- "sinon": "^19.0.2",
37
+ "shx": "^0.4.0",
38
+ "sinon": "^20.0.0",
39
39
  "source-map-loader": "^5.0.0",
40
40
  "stream-browserify": "^3.0.0",
41
41
  "string-replace-webpack-plugin": "^0.1.3",
42
42
  "svg-to-pdfkit": "^0.1.8",
43
- "terser-webpack-plugin": "^5.3.11",
43
+ "terser-webpack-plugin": "^5.3.14",
44
44
  "transform-loader": "^0.2.4",
45
45
  "util": "^0.12.5",
46
- "webpack": "^5.97.1",
46
+ "webpack": "^5.99.8",
47
47
  "webpack-cli": "^6.0.1"
48
48
  },
49
49
  "engines": {
@@ -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.
@@ -1043,6 +1043,27 @@ LayoutBuilder.prototype.buildNextLine = function (textNode) {
1043
1043
  return newInline;
1044
1044
  }
1045
1045
 
1046
+ function findMaxFitLength(text, maxWidth, measureFn) {
1047
+ let low = 1;
1048
+ let high = text.length;
1049
+ let bestFit = 1;
1050
+
1051
+ while (low <= high) {
1052
+ const mid = Math.floor((low + high) / 2);
1053
+ const part = text.substring(0, mid);
1054
+ const width = measureFn(part);
1055
+
1056
+ if (width <= maxWidth) {
1057
+ bestFit = mid;
1058
+ low = mid + 1;
1059
+ } else {
1060
+ high = mid - 1;
1061
+ }
1062
+ }
1063
+
1064
+ return bestFit;
1065
+ }
1066
+
1046
1067
  if (!textNode._inlines || textNode._inlines.length === 0) {
1047
1068
  return null;
1048
1069
  }
@@ -1058,11 +1079,9 @@ LayoutBuilder.prototype.buildNextLine = function (textNode) {
1058
1079
  isForceContinue = false;
1059
1080
 
1060
1081
  if (!inline.noWrap && inline.text.length > 1 && inline.width > line.getAvailableWidth()) {
1061
- var widthPerChar = inline.width / inline.text.length;
1062
- var maxChars = Math.floor(line.getAvailableWidth() / widthPerChar);
1063
- if (maxChars < 1) {
1064
- maxChars = 1;
1065
- }
1082
+ var maxChars = findMaxFitLength(inline.text, line.getAvailableWidth(), function (txt) {
1083
+ return textTools.widthOfString(txt, inline.font, inline.fontSize, inline.characterSpacing, inline.fontFeatures)
1084
+ });
1066
1085
  if (maxChars < inline.text.length) {
1067
1086
  var newInline = cloneInline(inline);
1068
1087