pdfmake 0.1.64 → 0.1.65
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/pdfmake.js +108 -141
- package/build/pdfmake.js.map +1 -1
- package/build/pdfmake.min.js +5 -5
- package/build/pdfmake.min.js.map +1 -1
- package/package.json +69 -69
- package/src/docMeasure.js +6 -1
- package/src/layoutBuilder.js +24 -28
- package/src/printer.js +18 -6
- package/src/styleContextStack.js +1 -0
- package/src/tableProcessor.js +7 -1
package/package.json
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
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.5.1",
|
|
12
|
-
"linebreak": "^1.0.2",
|
|
13
|
-
"pdfkit": "^0.11.0",
|
|
14
|
-
"svg-to-pdfkit": "^0.1.8"
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"@babel/core": "^7.8.4",
|
|
18
|
-
"@babel/plugin-transform-modules-commonjs": "^7.8.3",
|
|
19
|
-
"@babel/preset-env": "^7.8.4",
|
|
20
|
-
"babel-loader": "^8.0.6",
|
|
21
|
-
"brfs": "^2.0.2",
|
|
22
|
-
"eslint-plugin-jsdoc": "^21.0.0",
|
|
23
|
-
"expose-loader": "^0.7.5",
|
|
24
|
-
"fancy-log": "^1.3.3",
|
|
25
|
-
"file-saver": "^2.0.2",
|
|
26
|
-
"gulp": "^4.0.2",
|
|
27
|
-
"gulp-each": "^0.5.0",
|
|
28
|
-
"gulp-eslint": "^6.0.0",
|
|
29
|
-
"gulp-file-contents-to-json": "^0.2.2",
|
|
30
|
-
"gulp-spawn-mocha": "^6.0.0",
|
|
31
|
-
"mocha": "^7.0.1",
|
|
32
|
-
"rewire": "^4.0.1",
|
|
33
|
-
"sinon": "^8.1.1",
|
|
34
|
-
"string-replace-webpack-plugin": "^0.1.3",
|
|
35
|
-
"transform-loader": "^0.2.4",
|
|
36
|
-
"uglifyjs-webpack-plugin": "^2.2.0",
|
|
37
|
-
"webpack": "^4.41.5"
|
|
38
|
-
},
|
|
39
|
-
"scripts": {
|
|
40
|
-
"build": "gulp build",
|
|
41
|
-
"test": "gulp",
|
|
42
|
-
"playground": "node dev-playground/server.js"
|
|
43
|
-
},
|
|
44
|
-
"repository": {
|
|
45
|
-
"type": "git",
|
|
46
|
-
"url": "git://github.com/bpampuch/pdfmake.git"
|
|
47
|
-
},
|
|
48
|
-
"keywords": [
|
|
49
|
-
"pdf",
|
|
50
|
-
"javascript",
|
|
51
|
-
"printing",
|
|
52
|
-
"layout"
|
|
53
|
-
],
|
|
54
|
-
"author": "Bartek Pampuch <bartosz.pampuch@gmail.com>",
|
|
55
|
-
"license": "MIT",
|
|
56
|
-
"bugs": {
|
|
57
|
-
"url": "https://github.com/bpampuch/pdfmake/issues"
|
|
58
|
-
},
|
|
59
|
-
"homepage": "http://pdfmake.org",
|
|
60
|
-
"config": {
|
|
61
|
-
"blanket": {
|
|
62
|
-
"pattern": "src",
|
|
63
|
-
"data-cover-never": [
|
|
64
|
-
"node_modules",
|
|
65
|
-
"tests"
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "pdfmake",
|
|
3
|
+
"version": "0.1.65",
|
|
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.5.1",
|
|
12
|
+
"linebreak": "^1.0.2",
|
|
13
|
+
"pdfkit": "^0.11.0",
|
|
14
|
+
"svg-to-pdfkit": "^0.1.8"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@babel/core": "^7.8.4",
|
|
18
|
+
"@babel/plugin-transform-modules-commonjs": "^7.8.3",
|
|
19
|
+
"@babel/preset-env": "^7.8.4",
|
|
20
|
+
"babel-loader": "^8.0.6",
|
|
21
|
+
"brfs": "^2.0.2",
|
|
22
|
+
"eslint-plugin-jsdoc": "^21.0.0",
|
|
23
|
+
"expose-loader": "^0.7.5",
|
|
24
|
+
"fancy-log": "^1.3.3",
|
|
25
|
+
"file-saver": "^2.0.2",
|
|
26
|
+
"gulp": "^4.0.2",
|
|
27
|
+
"gulp-each": "^0.5.0",
|
|
28
|
+
"gulp-eslint": "^6.0.0",
|
|
29
|
+
"gulp-file-contents-to-json": "^0.2.2",
|
|
30
|
+
"gulp-spawn-mocha": "^6.0.0",
|
|
31
|
+
"mocha": "^7.0.1",
|
|
32
|
+
"rewire": "^4.0.1",
|
|
33
|
+
"sinon": "^8.1.1",
|
|
34
|
+
"string-replace-webpack-plugin": "^0.1.3",
|
|
35
|
+
"transform-loader": "^0.2.4",
|
|
36
|
+
"uglifyjs-webpack-plugin": "^2.2.0",
|
|
37
|
+
"webpack": "^4.41.5"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "gulp build",
|
|
41
|
+
"test": "gulp",
|
|
42
|
+
"playground": "node dev-playground/server.js"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git://github.com/bpampuch/pdfmake.git"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"pdf",
|
|
50
|
+
"javascript",
|
|
51
|
+
"printing",
|
|
52
|
+
"layout"
|
|
53
|
+
],
|
|
54
|
+
"author": "Bartek Pampuch <bartosz.pampuch@gmail.com>",
|
|
55
|
+
"license": "MIT",
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "https://github.com/bpampuch/pdfmake/issues"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "http://pdfmake.org",
|
|
60
|
+
"config": {
|
|
61
|
+
"blanket": {
|
|
62
|
+
"pattern": "src",
|
|
63
|
+
"data-cover-never": [
|
|
64
|
+
"node_modules",
|
|
65
|
+
"tests"
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
package/src/docMeasure.js
CHANGED
|
@@ -603,6 +603,7 @@ DocMeasure.prototype.measureTable = function (node) {
|
|
|
603
603
|
return function () {
|
|
604
604
|
if (isObject(data)) {
|
|
605
605
|
data.fillColor = _this.styleStack.getProperty('fillColor');
|
|
606
|
+
data.fillOpacity = _this.styleStack.getProperty('fillOpacity');
|
|
606
607
|
}
|
|
607
608
|
return _this.measureNode(data);
|
|
608
609
|
};
|
|
@@ -649,6 +650,9 @@ DocMeasure.prototype.measureTable = function (node) {
|
|
|
649
650
|
fillColor: function (i, node) {
|
|
650
651
|
return null;
|
|
651
652
|
},
|
|
653
|
+
fillOpacity: function (i, node) {
|
|
654
|
+
return 1;
|
|
655
|
+
},
|
|
652
656
|
defaultBorder: true
|
|
653
657
|
};
|
|
654
658
|
|
|
@@ -731,7 +735,8 @@ DocMeasure.prototype.measureTable = function (node) {
|
|
|
731
735
|
_span: true,
|
|
732
736
|
_minWidth: 0,
|
|
733
737
|
_maxWidth: 0,
|
|
734
|
-
fillColor: table.body[row][col].fillColor
|
|
738
|
+
fillColor: table.body[row][col].fillColor,
|
|
739
|
+
fillOpacity: table.body[row][col].fillOpacity
|
|
735
740
|
};
|
|
736
741
|
}
|
|
737
742
|
}
|
package/src/layoutBuilder.js
CHANGED
|
@@ -19,6 +19,7 @@ var getNodeId = require('./helpers').getNodeId;
|
|
|
19
19
|
var isFunction = require('./helpers').isFunction;
|
|
20
20
|
var TextTools = require('./textTools');
|
|
21
21
|
var StyleContextStack = require('./styleContextStack');
|
|
22
|
+
var isNumber = require('./helpers').isNumber;
|
|
22
23
|
|
|
23
24
|
function addAll(target, otherArray) {
|
|
24
25
|
otherArray.forEach(function (item) {
|
|
@@ -91,40 +92,35 @@ LayoutBuilder.prototype.layoutDocument = function (docStructure, fontProvider, s
|
|
|
91
92
|
node.nodeInfo = nodeInfo;
|
|
92
93
|
});
|
|
93
94
|
|
|
94
|
-
|
|
95
|
+
for (var index = 0; index < linearNodeList.length; index++) {
|
|
96
|
+
var node = linearNodeList[index];
|
|
95
97
|
if (node.pageBreak !== 'before' && !node.pageBreakCalculated) {
|
|
96
98
|
node.pageBreakCalculated = true;
|
|
97
99
|
var pageNumber = node.nodeInfo.pageNumbers[0];
|
|
98
|
-
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return node.nodeInfo;
|
|
116
|
-
}),
|
|
117
|
-
nodesOnNextPage.map(function (node) {
|
|
118
|
-
return node.nodeInfo;
|
|
119
|
-
}),
|
|
120
|
-
previousNodesOnPage.map(function (node) {
|
|
121
|
-
return node.nodeInfo;
|
|
122
|
-
}))) {
|
|
100
|
+
var followingNodesOnPage = [];
|
|
101
|
+
var nodesOnNextPage = [];
|
|
102
|
+
var previousNodesOnPage = [];
|
|
103
|
+
for (var ii = index + 1, l = linearNodeList.length; ii < l; ii++) {
|
|
104
|
+
if (linearNodeList[ii].nodeInfo.pageNumbers.indexOf(pageNumber) > -1) {
|
|
105
|
+
followingNodesOnPage.push(linearNodeList[ii].nodeInfo);
|
|
106
|
+
}
|
|
107
|
+
if (linearNodeList[ii].nodeInfo.pageNumbers.indexOf(pageNumber + 1) > -1) {
|
|
108
|
+
nodesOnNextPage.push(linearNodeList[ii].nodeInfo);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
for (var ii = 0; ii < index; ii++) {
|
|
112
|
+
if (linearNodeList[ii].nodeInfo.pageNumbers.indexOf(pageNumber) > -1) {
|
|
113
|
+
previousNodesOnPage.push(linearNodeList[ii].nodeInfo);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (pageBreakBeforeFct(node.nodeInfo, followingNodesOnPage, nodesOnNextPage, previousNodesOnPage)) {
|
|
123
117
|
node.pageBreak = 'before';
|
|
124
118
|
return true;
|
|
125
119
|
}
|
|
126
120
|
}
|
|
127
|
-
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return false;
|
|
128
124
|
}
|
|
129
125
|
|
|
130
126
|
this.docPreprocessor = new DocPreprocessor();
|
|
@@ -258,7 +254,7 @@ LayoutBuilder.prototype.addWatermark = function (watermark, fontProvider, defaul
|
|
|
258
254
|
watermark.font = watermark.font || defaultStyle.font || 'Roboto';
|
|
259
255
|
watermark.fontSize = watermark.fontSize || 'auto';
|
|
260
256
|
watermark.color = watermark.color || 'black';
|
|
261
|
-
watermark.opacity = watermark.opacity
|
|
257
|
+
watermark.opacity = isNumber(watermark.opacity) ? watermark.opacity : 0.6;
|
|
262
258
|
watermark.bold = watermark.bold || false;
|
|
263
259
|
watermark.italics = watermark.italics || false;
|
|
264
260
|
watermark.angle = !isUndefined(watermark.angle) && !isNull(watermark.angle) ? watermark.angle : null;
|
package/src/printer.js
CHANGED
|
@@ -475,7 +475,8 @@ function renderLine(line, x, y, pdfKitDoc) {
|
|
|
475
475
|
options.features = inline.fontFeatures;
|
|
476
476
|
}
|
|
477
477
|
|
|
478
|
-
|
|
478
|
+
var opacity = isNumber(inline.opacity) ? inline.opacity : 1;
|
|
479
|
+
pdfKitDoc.opacity(opacity);
|
|
479
480
|
pdfKitDoc.fill(inline.color || 'black');
|
|
480
481
|
|
|
481
482
|
pdfKitDoc._font = inline.font;
|
|
@@ -587,25 +588,36 @@ function renderVector(vector, pdfKitDoc) {
|
|
|
587
588
|
vector.color = gradient;
|
|
588
589
|
}
|
|
589
590
|
|
|
591
|
+
var fillOpacity = isNumber(vector.fillOpacity) ? vector.fillOpacity : 1;
|
|
592
|
+
var strokeOpacity = isNumber(vector.strokeOpacity) ? vector.strokeOpacity : 1;
|
|
593
|
+
|
|
590
594
|
if (vector.color && vector.lineColor) {
|
|
591
|
-
pdfKitDoc.fillColor(vector.color,
|
|
592
|
-
pdfKitDoc.strokeColor(vector.lineColor,
|
|
595
|
+
pdfKitDoc.fillColor(vector.color, fillOpacity);
|
|
596
|
+
pdfKitDoc.strokeColor(vector.lineColor, strokeOpacity);
|
|
593
597
|
pdfKitDoc.fillAndStroke();
|
|
594
598
|
} else if (vector.color) {
|
|
595
|
-
pdfKitDoc.fillColor(vector.color,
|
|
599
|
+
pdfKitDoc.fillColor(vector.color, fillOpacity);
|
|
596
600
|
pdfKitDoc.fill();
|
|
597
601
|
} else {
|
|
598
|
-
pdfKitDoc.strokeColor(vector.lineColor || 'black',
|
|
602
|
+
pdfKitDoc.strokeColor(vector.lineColor || 'black', strokeOpacity);
|
|
599
603
|
pdfKitDoc.stroke();
|
|
600
604
|
}
|
|
601
605
|
}
|
|
602
606
|
|
|
603
607
|
function renderImage(image, x, y, pdfKitDoc) {
|
|
604
|
-
|
|
608
|
+
var opacity = isNumber(image.opacity) ? image.opacity : 1;
|
|
609
|
+
pdfKitDoc.opacity(opacity);
|
|
605
610
|
pdfKitDoc.image(image.image, image.x, image.y, { width: image._width, height: image._height });
|
|
606
611
|
if (image.link) {
|
|
607
612
|
pdfKitDoc.link(image.x, image.y, image._width, image._height, image.link);
|
|
608
613
|
}
|
|
614
|
+
if (image.linkToPage) {
|
|
615
|
+
pdfKitDoc.ref({ Type: 'Action', S: 'GoTo', D: [image.linkToPage, 0, 0] }).end();
|
|
616
|
+
pdfKitDoc.annotate(image.x, image.y, image._width, image._height, { Subtype: 'Link', Dest: [image.linkToPage - 1, 'XYZ', null, null, null] });
|
|
617
|
+
}
|
|
618
|
+
if (image.linkToDestination) {
|
|
619
|
+
pdfKitDoc.goTo(image.x, image.y, image._width, image._height, image.linkToDestination);
|
|
620
|
+
}
|
|
609
621
|
}
|
|
610
622
|
|
|
611
623
|
function renderSVG(svg, x, y, pdfKitDoc, fontProvider) {
|
package/src/styleContextStack.js
CHANGED
package/src/tableProcessor.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var ColumnCalculator = require('./columnCalculator');
|
|
4
4
|
var isFunction = require('./helpers').isFunction;
|
|
5
|
+
var isNumber = require('./helpers').isNumber;
|
|
5
6
|
|
|
6
7
|
function TableProcessor(tableNode) {
|
|
7
8
|
this.tableNode = tableNode;
|
|
@@ -419,9 +420,13 @@ TableProcessor.prototype.endRow = function (rowIndex, writer, pageBreaks) {
|
|
|
419
420
|
|
|
420
421
|
if (i < l - 1) {
|
|
421
422
|
var fillColor = body[rowIndex][colIndex].fillColor;
|
|
423
|
+
var fillOpacity = body[rowIndex][colIndex].fillOpacity;
|
|
422
424
|
if (!fillColor) {
|
|
423
425
|
fillColor = isFunction(this.layout.fillColor) ? this.layout.fillColor(rowIndex, this.tableNode, colIndex) : this.layout.fillColor;
|
|
424
426
|
}
|
|
427
|
+
if (!isNumber(fillOpacity)) {
|
|
428
|
+
fillOpacity = isFunction(this.layout.fillOpacity) ? this.layout.fillOpacity(rowIndex, this.tableNode, colIndex) : this.layout.fillOpacity;
|
|
429
|
+
}
|
|
425
430
|
if (fillColor) {
|
|
426
431
|
var widthLeftBorder = leftCellBorder ? this.layout.vLineWidth(colIndex, this.tableNode) : 0;
|
|
427
432
|
var widthRightBorder;
|
|
@@ -444,7 +449,8 @@ TableProcessor.prototype.endRow = function (rowIndex, writer, pageBreaks) {
|
|
|
444
449
|
w: x2f - x1f,
|
|
445
450
|
h: y2f - y1f,
|
|
446
451
|
lineWidth: 0,
|
|
447
|
-
color: fillColor
|
|
452
|
+
color: fillColor,
|
|
453
|
+
fillOpacity: fillOpacity
|
|
448
454
|
}, false, true, writer.context().backgroundLength[writer.context().page]);
|
|
449
455
|
}
|
|
450
456
|
}
|