pdfmake 0.2.14 → 0.2.16
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/CHANGELOG.md +18 -0
- package/build/pdfmake.js +39163 -38748
- package/build/pdfmake.js.map +1 -1
- package/build/pdfmake.min.js +2 -2
- package/build/pdfmake.min.js.map +1 -1
- package/build/vfs_fonts.js +2 -2
- package/build-vfs.js +2 -2
- package/package.json +24 -22
- package/src/browser-extensions/pdfMake.js +30 -4
- package/src/documentContext.js +13 -1
- package/src/imageMeasure.js +10 -1
- package/src/layoutBuilder.js +1126 -989
- package/src/printer.js +17 -0
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/pdfmake.iml +0 -11
- package/.idea/vcs.xml +0 -6
package/build-vfs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
|
|
3
|
-
const vfsBefore = "
|
|
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
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdfmake",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
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.
|
|
12
|
-
"@foliojs-fork/pdfkit": "^0.
|
|
11
|
+
"@foliojs-fork/linebreak": "^1.1.2",
|
|
12
|
+
"@foliojs-fork/pdfkit": "^0.15.2",
|
|
13
13
|
"iconv-lite": "^0.6.3",
|
|
14
|
-
"xmldoc": "^1.
|
|
14
|
+
"xmldoc": "^1.3.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@babel/cli": "^7.
|
|
18
|
-
"@babel/core": "^7.
|
|
19
|
-
"@babel/plugin-transform-modules-commonjs": "^7.
|
|
20
|
-
"@babel/preset-env": "^7.
|
|
21
|
-
"
|
|
22
|
-
"
|
|
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": "^
|
|
28
|
-
"eslint-plugin-jsdoc": "^
|
|
29
|
-
"expose-loader": "^
|
|
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
|
-
"
|
|
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": "^
|
|
35
|
-
"shx": "^0.3.
|
|
36
|
-
"sinon": "^
|
|
37
|
-
"source-map-loader": "^
|
|
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.
|
|
43
|
+
"terser-webpack-plugin": "^5.3.10",
|
|
42
44
|
"transform-loader": "^0.2.4",
|
|
43
|
-
"util": "^0.12.
|
|
44
|
-
"webpack": "^5.
|
|
45
|
-
"webpack-cli": "^
|
|
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"
|
|
@@ -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
|
};
|
package/src/documentContext.js
CHANGED
|
@@ -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) {
|
package/src/imageMeasure.js
CHANGED
|
@@ -26,7 +26,16 @@ ImageMeasure.prototype.measureImage = function (src) {
|
|
|
26
26
|
image = this.pdfKitDoc._imageRegistry[src];
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
var imageSize = { width: image.width, height: image.height };
|
|
30
|
+
|
|
31
|
+
if (typeof image === 'object' && image.constructor.name === 'JPEG') {
|
|
32
|
+
// If EXIF orientation calls for it, swap width and height
|
|
33
|
+
if (image.orientation > 4) {
|
|
34
|
+
imageSize = { width: image.height, height: image.width };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return imageSize;
|
|
30
39
|
|
|
31
40
|
function realImageSrc(src) {
|
|
32
41
|
var img = that.imageDictionary[src];
|