pdfmake 0.3.0-beta.3 → 0.3.0-beta.5
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 +9 -0
- package/build/pdfmake.js +2213 -8630
- 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 +6 -5
- package/js/3rd-party/svg-to-pdfkit/source.js +247 -920
- package/js/3rd-party/svg-to-pdfkit.js +0 -3
- package/js/DocMeasure.js +6 -139
- package/js/DocPreprocessor.js +2 -54
- package/js/DocumentContext.js +0 -40
- package/js/ElementWriter.js +2 -70
- package/js/LayoutBuilder.js +20 -165
- package/js/Line.js +6 -25
- package/js/OutputDocument.js +15 -24
- package/js/OutputDocumentServer.js +0 -6
- package/js/PDFDocument.js +1 -46
- package/js/PageElementWriter.js +7 -31
- package/js/PageSize.js +2 -16
- package/js/Printer.js +5 -46
- package/js/Renderer.js +11 -98
- package/js/SVGMeasure.js +1 -20
- package/js/StyleContextStack.js +12 -36
- package/js/TableProcessor.js +36 -117
- package/js/TextBreaker.js +2 -44
- package/js/TextDecorator.js +1 -38
- package/js/TextInlines.js +8 -49
- package/js/URLResolver.js +0 -13
- package/js/base.js +1 -17
- package/js/browser-extensions/OutputDocumentBrowser.js +5 -17
- package/js/browser-extensions/URLBrowserResolver.js +0 -17
- package/js/browser-extensions/fonts/Roboto.js +0 -4
- package/js/browser-extensions/index.js +0 -16
- package/js/browser-extensions/pdfMake.js +2 -4
- package/js/browser-extensions/standard-fonts/Courier.js +0 -4
- package/js/browser-extensions/standard-fonts/Helvetica.js +0 -4
- package/js/browser-extensions/standard-fonts/Symbol.js +0 -4
- package/js/browser-extensions/standard-fonts/Times.js +0 -4
- package/js/browser-extensions/standard-fonts/ZapfDingbats.js +0 -4
- package/js/columnCalculator.js +6 -18
- package/js/helpers/node.js +3 -27
- package/js/helpers/tools.js +0 -8
- package/js/helpers/variableType.js +4 -9
- package/js/index.js +0 -6
- package/js/qrEnc.js +126 -215
- package/js/tableLayouts.js +1 -28
- package/js/virtual-fs.js +3 -19
- package/package.json +2 -2
- package/src/OutputDocument.js +78 -78
package/js/tableLayouts.js
CHANGED
|
@@ -2,74 +2,59 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.tableLayouts = exports.defaultTableLayout = void 0;
|
|
5
|
-
|
|
6
5
|
/*eslint no-unused-vars: ["error", {"args": "none"}]*/
|
|
6
|
+
|
|
7
7
|
const tableLayouts = {
|
|
8
8
|
noBorders: {
|
|
9
9
|
hLineWidth(i) {
|
|
10
10
|
return 0;
|
|
11
11
|
},
|
|
12
|
-
|
|
13
12
|
vLineWidth(i) {
|
|
14
13
|
return 0;
|
|
15
14
|
},
|
|
16
|
-
|
|
17
15
|
paddingLeft(i) {
|
|
18
16
|
return i && 4 || 0;
|
|
19
17
|
},
|
|
20
|
-
|
|
21
18
|
paddingRight(i, node) {
|
|
22
19
|
return i < node.table.widths.length - 1 ? 4 : 0;
|
|
23
20
|
}
|
|
24
|
-
|
|
25
21
|
},
|
|
26
22
|
headerLineOnly: {
|
|
27
23
|
hLineWidth(i, node) {
|
|
28
24
|
if (i === 0 || i === node.table.body.length) {
|
|
29
25
|
return 0;
|
|
30
26
|
}
|
|
31
|
-
|
|
32
27
|
return i === node.table.headerRows ? 2 : 0;
|
|
33
28
|
},
|
|
34
|
-
|
|
35
29
|
vLineWidth(i) {
|
|
36
30
|
return 0;
|
|
37
31
|
},
|
|
38
|
-
|
|
39
32
|
paddingLeft(i) {
|
|
40
33
|
return i === 0 ? 0 : 8;
|
|
41
34
|
},
|
|
42
|
-
|
|
43
35
|
paddingRight(i, node) {
|
|
44
36
|
return i === node.table.widths.length - 1 ? 0 : 8;
|
|
45
37
|
}
|
|
46
|
-
|
|
47
38
|
},
|
|
48
39
|
lightHorizontalLines: {
|
|
49
40
|
hLineWidth(i, node) {
|
|
50
41
|
if (i === 0 || i === node.table.body.length) {
|
|
51
42
|
return 0;
|
|
52
43
|
}
|
|
53
|
-
|
|
54
44
|
return i === node.table.headerRows ? 2 : 1;
|
|
55
45
|
},
|
|
56
|
-
|
|
57
46
|
vLineWidth(i) {
|
|
58
47
|
return 0;
|
|
59
48
|
},
|
|
60
|
-
|
|
61
49
|
hLineColor(i) {
|
|
62
50
|
return i === 1 ? 'black' : '#aaa';
|
|
63
51
|
},
|
|
64
|
-
|
|
65
52
|
paddingLeft(i) {
|
|
66
53
|
return i === 0 ? 0 : 8;
|
|
67
54
|
},
|
|
68
|
-
|
|
69
55
|
paddingRight(i, node) {
|
|
70
56
|
return i === node.table.widths.length - 1 ? 0 : 8;
|
|
71
57
|
}
|
|
72
|
-
|
|
73
58
|
}
|
|
74
59
|
};
|
|
75
60
|
exports.tableLayouts = tableLayouts;
|
|
@@ -77,51 +62,39 @@ const defaultTableLayout = {
|
|
|
77
62
|
hLineWidth(i, node) {
|
|
78
63
|
return 1;
|
|
79
64
|
},
|
|
80
|
-
|
|
81
65
|
vLineWidth(i, node) {
|
|
82
66
|
return 1;
|
|
83
67
|
},
|
|
84
|
-
|
|
85
68
|
hLineColor(i, node) {
|
|
86
69
|
return 'black';
|
|
87
70
|
},
|
|
88
|
-
|
|
89
71
|
vLineColor(i, node) {
|
|
90
72
|
return 'black';
|
|
91
73
|
},
|
|
92
|
-
|
|
93
74
|
hLineStyle(i, node) {
|
|
94
75
|
return null;
|
|
95
76
|
},
|
|
96
|
-
|
|
97
77
|
vLineStyle(i, node) {
|
|
98
78
|
return null;
|
|
99
79
|
},
|
|
100
|
-
|
|
101
80
|
paddingLeft(i, node) {
|
|
102
81
|
return 4;
|
|
103
82
|
},
|
|
104
|
-
|
|
105
83
|
paddingRight(i, node) {
|
|
106
84
|
return 4;
|
|
107
85
|
},
|
|
108
|
-
|
|
109
86
|
paddingTop(i, node) {
|
|
110
87
|
return 2;
|
|
111
88
|
},
|
|
112
|
-
|
|
113
89
|
paddingBottom(i, node) {
|
|
114
90
|
return 2;
|
|
115
91
|
},
|
|
116
|
-
|
|
117
92
|
fillColor(i, node) {
|
|
118
93
|
return null;
|
|
119
94
|
},
|
|
120
|
-
|
|
121
95
|
fillOpacity(i, node) {
|
|
122
96
|
return 1;
|
|
123
97
|
},
|
|
124
|
-
|
|
125
98
|
defaultBorder: true
|
|
126
99
|
};
|
|
127
100
|
exports.defaultTableLayout = defaultTableLayout;
|
package/js/virtual-fs.js
CHANGED
|
@@ -2,76 +2,60 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.default = void 0;
|
|
5
|
-
|
|
6
5
|
const normalizeFilename = filename => {
|
|
7
6
|
if (filename.indexOf(__dirname) === 0) {
|
|
8
7
|
filename = filename.substring(__dirname.length);
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
if (filename.indexOf('/') === 0) {
|
|
12
10
|
filename = filename.substring(1);
|
|
13
11
|
}
|
|
14
|
-
|
|
15
12
|
return filename;
|
|
16
13
|
};
|
|
17
|
-
|
|
18
14
|
class VirtualFileSystem {
|
|
19
15
|
constructor() {
|
|
20
16
|
this.storage = {};
|
|
21
17
|
}
|
|
18
|
+
|
|
22
19
|
/**
|
|
23
20
|
* @param {string} filename
|
|
24
21
|
* @returns {boolean}
|
|
25
22
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
23
|
existsSync(filename) {
|
|
29
24
|
const normalizedFilename = normalizeFilename(filename);
|
|
30
25
|
return typeof this.storage[normalizedFilename] !== 'undefined';
|
|
31
26
|
}
|
|
27
|
+
|
|
32
28
|
/**
|
|
33
29
|
* @param {string} filename
|
|
34
30
|
* @param {?string|?object} options
|
|
35
31
|
* @returns {string|Buffer}
|
|
36
32
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
33
|
readFileSync(filename, options) {
|
|
40
34
|
const normalizedFilename = normalizeFilename(filename);
|
|
41
35
|
const encoding = typeof options === 'object' ? options.encoding : options;
|
|
42
|
-
|
|
43
36
|
if (!this.existsSync(normalizedFilename)) {
|
|
44
37
|
throw new Error(`File '${normalizedFilename}' not found in virtual file system`);
|
|
45
38
|
}
|
|
46
|
-
|
|
47
39
|
const buffer = this.storage[normalizedFilename];
|
|
48
|
-
|
|
49
40
|
if (encoding) {
|
|
50
41
|
return buffer.toString(encoding);
|
|
51
42
|
}
|
|
52
|
-
|
|
53
43
|
return buffer;
|
|
54
44
|
}
|
|
45
|
+
|
|
55
46
|
/**
|
|
56
47
|
* @param {string} filename
|
|
57
48
|
* @param {string|Buffer} content
|
|
58
49
|
* @param {?string|?object} options
|
|
59
50
|
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
51
|
writeFileSync(filename, content, options) {
|
|
63
52
|
const normalizedFilename = normalizeFilename(filename);
|
|
64
53
|
const encoding = typeof options === 'object' ? options.encoding : options;
|
|
65
|
-
|
|
66
54
|
if (!content && !options) {
|
|
67
55
|
throw new Error('No content');
|
|
68
56
|
}
|
|
69
|
-
|
|
70
57
|
this.storage[normalizedFilename] = encoding || typeof content === 'string' ? new Buffer(content, encoding) : content;
|
|
71
58
|
}
|
|
72
|
-
|
|
73
59
|
}
|
|
74
|
-
|
|
75
60
|
var _default = new VirtualFileSystem();
|
|
76
|
-
|
|
77
61
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdfmake",
|
|
3
|
-
"version": "0.3.0-beta.
|
|
3
|
+
"version": "0.3.0-beta.5",
|
|
4
4
|
"description": "Client/server side PDF printing in pure JavaScript",
|
|
5
5
|
"main": "js/index.js",
|
|
6
6
|
"esnext": "src/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"webpack-cli": "^4.9.1"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
|
-
"node": ">=
|
|
48
|
+
"node": ">=14"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"test": "run-s build mocha lint",
|
package/src/OutputDocument.js
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
class OutputDocument {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @param {Promise<object>} pdfDocumentPromise
|
|
5
|
-
*/
|
|
6
|
-
constructor(pdfDocumentPromise) {
|
|
7
|
-
this.bufferSize =
|
|
8
|
-
this.pdfDocumentPromise = pdfDocumentPromise;
|
|
9
|
-
this.bufferPromise = null;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @returns {Promise<object>}
|
|
14
|
-
*/
|
|
15
|
-
getStream() {
|
|
16
|
-
return this.pdfDocumentPromise;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @returns {Promise<Buffer>}
|
|
21
|
-
*/
|
|
22
|
-
getBuffer() {
|
|
23
|
-
if (this.bufferPromise === null) {
|
|
24
|
-
this.bufferPromise = new Promise((resolve, reject) => {
|
|
25
|
-
this.getStream().then(stream => {
|
|
26
|
-
|
|
27
|
-
let chunks = [];
|
|
28
|
-
let result;
|
|
29
|
-
stream.on('readable', () => {
|
|
30
|
-
let chunk;
|
|
31
|
-
while ((chunk = stream.read(this.bufferSize)) !== null) {
|
|
32
|
-
chunks.push(chunk);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
stream.on('end', () => {
|
|
36
|
-
result = Buffer.concat(chunks);
|
|
37
|
-
resolve(result);
|
|
38
|
-
});
|
|
39
|
-
stream.end();
|
|
40
|
-
|
|
41
|
-
}, result => {
|
|
42
|
-
reject(result);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return this.bufferPromise;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @returns {Promise<string>}
|
|
52
|
-
*/
|
|
53
|
-
getBase64() {
|
|
54
|
-
return new Promise((resolve, reject) => {
|
|
55
|
-
this.getBuffer().then(buffer => {
|
|
56
|
-
resolve(buffer.toString('base64'));
|
|
57
|
-
}, result => {
|
|
58
|
-
reject(result);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @returns {Promise<string>}
|
|
65
|
-
*/
|
|
66
|
-
getDataUrl() {
|
|
67
|
-
return new Promise((resolve, reject) => {
|
|
68
|
-
this.getBase64().then(data => {
|
|
69
|
-
resolve('data:application/pdf;base64,' + data);
|
|
70
|
-
}, result => {
|
|
71
|
-
reject(result);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export default OutputDocument;
|
|
1
|
+
class OutputDocument {
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {Promise<object>} pdfDocumentPromise
|
|
5
|
+
*/
|
|
6
|
+
constructor(pdfDocumentPromise) {
|
|
7
|
+
this.bufferSize = 1073741824;
|
|
8
|
+
this.pdfDocumentPromise = pdfDocumentPromise;
|
|
9
|
+
this.bufferPromise = null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @returns {Promise<object>}
|
|
14
|
+
*/
|
|
15
|
+
getStream() {
|
|
16
|
+
return this.pdfDocumentPromise;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @returns {Promise<Buffer>}
|
|
21
|
+
*/
|
|
22
|
+
getBuffer() {
|
|
23
|
+
if (this.bufferPromise === null) {
|
|
24
|
+
this.bufferPromise = new Promise((resolve, reject) => {
|
|
25
|
+
this.getStream().then(stream => {
|
|
26
|
+
|
|
27
|
+
let chunks = [];
|
|
28
|
+
let result;
|
|
29
|
+
stream.on('readable', () => {
|
|
30
|
+
let chunk;
|
|
31
|
+
while ((chunk = stream.read(this.bufferSize)) !== null) {
|
|
32
|
+
chunks.push(chunk);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
stream.on('end', () => {
|
|
36
|
+
result = Buffer.concat(chunks);
|
|
37
|
+
resolve(result);
|
|
38
|
+
});
|
|
39
|
+
stream.end();
|
|
40
|
+
|
|
41
|
+
}, result => {
|
|
42
|
+
reject(result);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return this.bufferPromise;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @returns {Promise<string>}
|
|
52
|
+
*/
|
|
53
|
+
getBase64() {
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
this.getBuffer().then(buffer => {
|
|
56
|
+
resolve(buffer.toString('base64'));
|
|
57
|
+
}, result => {
|
|
58
|
+
reject(result);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @returns {Promise<string>}
|
|
65
|
+
*/
|
|
66
|
+
getDataUrl() {
|
|
67
|
+
return new Promise((resolve, reject) => {
|
|
68
|
+
this.getBase64().then(data => {
|
|
69
|
+
resolve('data:application/pdf;base64,' + data);
|
|
70
|
+
}, result => {
|
|
71
|
+
reject(result);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default OutputDocument;
|