pdfmake 0.3.0-beta.6 → 0.3.0-beta.7

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.
@@ -2722,7 +2722,6 @@ var SVGtoPDF = function (doc, svg, x, y, options) {
2722
2722
  }
2723
2723
  r2 = Math.max(r2, d * multiplier * (1 + 1e-6)); // fix for edge-case gradients see issue #84
2724
2724
  }
2725
-
2726
2725
  if (spread === 'reflect' || spread === 'repeat') {
2727
2726
  let inv = inverseMatrix(matrix),
2728
2727
  corner1 = transformPoint([bBox[0], bBox[1]], inv),
@@ -2740,7 +2739,6 @@ var SVGtoPDF = function (doc, svg, x, y, options) {
2740
2739
  nBefore = Math.ceil(nBefore + 0.5);
2741
2740
  nTotal = nBefore + 1 + nAfter; // How many times the gradient needs to be repeated to fill the object bounding box
2742
2741
  }
2743
-
2744
2742
  if (this.name === 'linearGradient') {
2745
2743
  grad = doc.linearGradient(x1 - nBefore * (x2 - x1), y1 - nBefore * (y2 - y1), x2 + nAfter * (x2 - x1), y2 + nAfter * (y2 - y1));
2746
2744
  } else {
package/js/DocMeasure.js CHANGED
@@ -77,6 +77,9 @@ class DocMeasure {
77
77
  let factor = dimensions.width / dimensions.height > node.fit[0] / node.fit[1] ? node.fit[0] / dimensions.width : node.fit[1] / dimensions.height;
78
78
  node._width = node._minWidth = node._maxWidth = dimensions.width * factor;
79
79
  node._height = dimensions.height * factor;
80
+ } else if (node.cover) {
81
+ node._width = node._minWidth = node._maxWidth = node.cover.width;
82
+ node._height = node._minHeight = node._maxHeight = node.cover.height;
80
83
  } else {
81
84
  node._width = node._minWidth = node._maxWidth = node.width || dimensions.width;
82
85
  node._height = node.height || dimensions.height * node._width / dimensions.width;
package/js/Printer.js CHANGED
@@ -63,6 +63,7 @@ class PdfPrinter {
63
63
  userPassword: docDefinition.userPassword,
64
64
  ownerPassword: docDefinition.ownerPassword,
65
65
  permissions: docDefinition.permissions,
66
+ lang: docDefinition.language,
66
67
  fontLayoutCache: typeof options.fontLayoutCache === 'boolean' ? options.fontLayoutCache : true,
67
68
  bufferPages: options.bufferPages || false,
68
69
  autoFirstPage: false,
@@ -83,7 +83,6 @@ class StyleContextStack {
83
83
  // 'evenRowCellBorder',
84
84
  // 'tableBorder'
85
85
  ];
86
-
87
86
  let styleOverrideObject = {};
88
87
  let pushStyleOverrideObject = false;
89
88
  styleProperties.forEach(key => {
@@ -97,6 +97,9 @@ class TableProcessor {
97
97
  this.rowSpanData = prepareRowSpanData();
98
98
  this.cleanUpRepeatables = false;
99
99
  this.headerRows = tableNode.table.headerRows || 0;
100
+ if (this.headerRows > tableNode.table.body.length) {
101
+ throw new Error(`Too few rows in the table. Property headerRows requires at least ${this.headerRows}, contains only ${tableNode.table.body.length}`);
102
+ }
100
103
  this.rowsWithoutPageBreak = this.headerRows + (tableNode.table.keepWithHeaderRows || 0);
101
104
  this.dontBreakRows = tableNode.table.dontBreakRows || false;
102
105
  if (this.rowsWithoutPageBreak) {
@@ -97,7 +97,7 @@ class TextDecorator {
97
97
  y += lineAscent - ascent * 0.25;
98
98
  break;
99
99
  default:
100
- throw new Error(`Unkown decoration : ${group.decoration}`);
100
+ throw new Error(`Unknown decoration : ${group.decoration}`);
101
101
  }
102
102
  this.pdfDocument.save();
103
103
  if (group.decorationStyle === 'double') {
package/js/qrEnc.js CHANGED
@@ -483,7 +483,6 @@ var putformatinfo = function (matrix, reserved, ecclevel, mask) {
483
483
  // we don't have to mark those bits reserved; always done
484
484
  // in makebasematrix above.
485
485
  }
486
-
487
486
  return matrix;
488
487
  };
489
488
 
@@ -675,11 +674,13 @@ function buildCanvas(data, options) {
675
674
  var canvas = [];
676
675
  var background = options.background || '#fff';
677
676
  var foreground = options.foreground || '#000';
677
+ var padding = options.padding || 0;
678
678
  //var margin = options.margin || 4;
679
679
  var matrix = generateFrame(data, options);
680
680
  var n = matrix.length;
681
681
  var modSize = Math.floor(options.fit ? options.fit / n : 5);
682
- var size = n * modSize;
682
+ var size = n * modSize + modSize * padding * 2;
683
+ var paddingXY = modSize * padding;
683
684
  canvas.push({
684
685
  type: 'rect',
685
686
  x: 0,
@@ -694,8 +695,8 @@ function buildCanvas(data, options) {
694
695
  if (matrix[i][j]) {
695
696
  canvas.push({
696
697
  type: 'rect',
697
- x: modSize * j,
698
- y: modSize * i,
698
+ x: modSize * j + paddingXY,
699
+ y: modSize * i + paddingXY,
699
700
  w: modSize,
700
701
  h: modSize,
701
702
  lineWidth: 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pdfmake",
3
- "version": "0.3.0-beta.6",
3
+ "version": "0.3.0-beta.7",
4
4
  "description": "Client/server side PDF printing in pure JavaScript",
5
5
  "main": "js/index.js",
6
6
  "esnext": "src/index.js",
@@ -12,40 +12,41 @@
12
12
  "@foliojs-fork/linebreak": "^1.1.1",
13
13
  "@foliojs-fork/pdfkit": "^0.14.0",
14
14
  "iconv-lite": "^0.6.3",
15
- "xmldoc": "^1.1.2"
15
+ "xmldoc": "^1.3.0"
16
16
  },
17
17
  "devDependencies": {
18
- "@babel/cli": "^7.16.7",
19
- "@babel/core": "^7.16.7",
20
- "@babel/plugin-transform-modules-commonjs": "^7.16.7",
21
- "@babel/preset-env": "^7.16.7",
22
- "assert": "^2.0.0",
23
- "babel-loader": "^8.2.3",
18
+ "@babel/cli": "^7.23.4",
19
+ "@babel/core": "^7.23.6",
20
+ "@babel/plugin-transform-modules-commonjs": "^7.23.3",
21
+ "@babel/preset-env": "^7.23.6",
22
+ "assert": "^2.1.0",
23
+ "babel-loader": "^9.1.3",
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": "^8.5.0",
29
- "eslint-plugin-jsdoc": "^37.4.2",
30
- "expose-loader": "^3.1.0",
28
+ "eslint": "^8.55.0",
29
+ "eslint-plugin-jsdoc": "^46.9.1",
30
+ "expose-loader": "^4.1.0",
31
31
  "file-saver": "^2.0.5",
32
- "mocha": "^9.1.3",
32
+ "mocha": "^10.2.0",
33
33
  "npm-run-all": "^4.1.5",
34
34
  "process": "^0.11.10",
35
- "rewire": "^6.0.0",
36
- "shx": "^0.3.3",
37
- "sinon": "^12.0.1",
35
+ "rewire": "^7.0.0",
36
+ "shx": "^0.3.4",
37
+ "sinon": "^17.0.1",
38
+ "source-map-loader": "^4.0.1",
38
39
  "stream-browserify": "^3.0.0",
39
40
  "string-replace-webpack-plugin": "^0.1.3",
40
41
  "svg-to-pdfkit": "^0.1.8",
41
- "terser-webpack-plugin": "^5.3.0",
42
+ "terser-webpack-plugin": "^5.3.9",
42
43
  "transform-loader": "^0.2.4",
43
- "util": "^0.12.4",
44
- "webpack": "^5.65.0",
45
- "webpack-cli": "^4.9.1"
44
+ "util": "^0.12.5",
45
+ "webpack": "^5.89.0",
46
+ "webpack-cli": "^5.1.4"
46
47
  },
47
48
  "engines": {
48
- "node": ">=14"
49
+ "node": ">=16"
49
50
  },
50
51
  "scripts": {
51
52
  "test": "run-s build mocha lint",
package/src/DocMeasure.js CHANGED
@@ -85,6 +85,9 @@ class DocMeasure {
85
85
  let factor = (dimensions.width / dimensions.height > node.fit[0] / node.fit[1]) ? node.fit[0] / dimensions.width : node.fit[1] / dimensions.height;
86
86
  node._width = node._minWidth = node._maxWidth = dimensions.width * factor;
87
87
  node._height = dimensions.height * factor;
88
+ } else if (node.cover) {
89
+ node._width = node._minWidth = node._maxWidth = node.cover.width;
90
+ node._height = node._minHeight = node._maxHeight = node.cover.height;
88
91
  } else {
89
92
  node._width = node._minWidth = node._maxWidth = node.width || dimensions.width;
90
93
  node._height = node.height || (dimensions.height * node._width / dimensions.width);
package/src/Printer.js CHANGED
@@ -62,6 +62,7 @@ class PdfPrinter {
62
62
  userPassword: docDefinition.userPassword,
63
63
  ownerPassword: docDefinition.ownerPassword,
64
64
  permissions: docDefinition.permissions,
65
+ lang: docDefinition.language,
65
66
  fontLayoutCache: typeof options.fontLayoutCache === 'boolean' ? options.fontLayoutCache : true,
66
67
  bufferPages: options.bufferPages || false,
67
68
  autoFirstPage: false,
@@ -102,6 +102,10 @@ class TableProcessor {
102
102
  this.cleanUpRepeatables = false;
103
103
 
104
104
  this.headerRows = tableNode.table.headerRows || 0;
105
+ if (this.headerRows > tableNode.table.body.length) {
106
+ throw new Error(`Too few rows in the table. Property headerRows requires at least ${this.headerRows}, contains only ${tableNode.table.body.length}`);
107
+ }
108
+
105
109
  this.rowsWithoutPageBreak = this.headerRows + (tableNode.table.keepWithHeaderRows || 0);
106
110
  this.dontBreakRows = tableNode.table.dontBreakRows || false;
107
111
 
@@ -109,7 +109,7 @@ class TextDecorator {
109
109
  y += lineAscent - (ascent * 0.25);
110
110
  break;
111
111
  default:
112
- throw new Error(`Unkown decoration : ${group.decoration}`);
112
+ throw new Error(`Unknown decoration : ${group.decoration}`);
113
113
  }
114
114
  this.pdfDocument.save();
115
115
 
package/src/qrEnc.js CHANGED
@@ -748,11 +748,13 @@ function buildCanvas(data, options) {
748
748
  var canvas = [];
749
749
  var background = options.background || '#fff';
750
750
  var foreground = options.foreground || '#000';
751
+ var padding = options.padding || 0;
751
752
  //var margin = options.margin || 4;
752
753
  var matrix = generateFrame(data, options);
753
754
  var n = matrix.length;
754
755
  var modSize = Math.floor(options.fit ? options.fit / n : 5);
755
- var size = n * modSize;
756
+ var size = (n * modSize) + (modSize * padding * 2);
757
+ var paddingXY = modSize * padding;
756
758
 
757
759
  canvas.push({
758
760
  type: 'rect',
@@ -764,8 +766,8 @@ function buildCanvas(data, options) {
764
766
  if (matrix[i][j]) {
765
767
  canvas.push({
766
768
  type: 'rect',
767
- x: modSize * j,
768
- y: modSize * i,
769
+ x: modSize * j + paddingXY,
770
+ y: modSize * i + paddingXY,
769
771
  w: modSize,
770
772
  h: modSize,
771
773
  lineWidth: 0,