pdfmake 0.3.0-beta.7 → 0.3.0-beta.8
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 +4 -0
- package/build/pdfmake.js +2654 -2525
- package/build/pdfmake.js.map +1 -1
- package/build/pdfmake.min.js +2 -2
- package/build/pdfmake.min.js.map +1 -1
- package/package.json +1 -1
- package/js/3rd-party/svg-to-pdfkit/source.js +0 -3626
- package/js/3rd-party/svg-to-pdfkit.js +0 -7
- package/js/DocMeasure.js +0 -627
- package/js/DocPreprocessor.js +0 -238
- package/js/DocumentContext.js +0 -265
- package/js/ElementWriter.js +0 -331
- package/js/LayoutBuilder.js +0 -694
- package/js/Line.js +0 -105
- package/js/OutputDocument.js +0 -76
- package/js/OutputDocumentServer.js +0 -27
- package/js/PDFDocument.js +0 -144
- package/js/PageElementWriter.js +0 -140
- package/js/PageSize.js +0 -74
- package/js/Printer.js +0 -291
- package/js/Renderer.js +0 -375
- package/js/SVGMeasure.js +0 -69
- package/js/StyleContextStack.js +0 -180
- package/js/TableProcessor.js +0 -511
- package/js/TextBreaker.js +0 -139
- package/js/TextDecorator.js +0 -143
- package/js/TextInlines.js +0 -206
- package/js/URLResolver.js +0 -73
- package/js/base.js +0 -52
- package/js/browser-extensions/OutputDocumentBrowser.js +0 -118
- package/js/browser-extensions/URLBrowserResolver.js +0 -76
- package/js/browser-extensions/fonts/Roboto.js +0 -38
- package/js/browser-extensions/index.js +0 -53
- package/js/browser-extensions/pdfMake.js +0 -15
- package/js/browser-extensions/standard-fonts/Courier.js +0 -38
- package/js/browser-extensions/standard-fonts/Helvetica.js +0 -38
- package/js/browser-extensions/standard-fonts/Symbol.js +0 -23
- package/js/browser-extensions/standard-fonts/Times.js +0 -38
- package/js/browser-extensions/standard-fonts/ZapfDingbats.js +0 -23
- package/js/browser-extensions/virtual-fs-cjs.js +0 -3
- package/js/columnCalculator.js +0 -129
- package/js/helpers/node.js +0 -98
- package/js/helpers/tools.js +0 -40
- package/js/helpers/variableType.js +0 -47
- package/js/index.js +0 -15
- package/js/qrEnc.js +0 -721
- package/js/standardPageSizes.js +0 -56
- package/js/tableLayouts.js +0 -98
- package/js/virtual-fs.js +0 -60
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var fs = require('fs');
|
|
4
|
-
var fontContainer = {
|
|
5
|
-
vfs: {
|
|
6
|
-
'Roboto-Regular.ttf': {
|
|
7
|
-
data: fs.readFileSync(__dirname + '/../../../fonts/Roboto/Roboto-Regular.ttf', 'base64'),
|
|
8
|
-
encoding: 'base64'
|
|
9
|
-
},
|
|
10
|
-
'Roboto-Medium.ttf': {
|
|
11
|
-
data: fs.readFileSync(__dirname + '/../../../fonts/Roboto/Roboto-Medium.ttf', 'base64'),
|
|
12
|
-
encoding: 'base64'
|
|
13
|
-
},
|
|
14
|
-
'Roboto-Italic.ttf': {
|
|
15
|
-
data: fs.readFileSync(__dirname + '/../../../fonts/Roboto/Roboto-Italic.ttf', 'base64'),
|
|
16
|
-
encoding: 'base64'
|
|
17
|
-
},
|
|
18
|
-
'Roboto-MediumItalic.ttf': {
|
|
19
|
-
data: fs.readFileSync(__dirname + '/../../../fonts/Roboto/Roboto-MediumItalic.ttf', 'base64'),
|
|
20
|
-
encoding: 'base64'
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
fonts: {
|
|
24
|
-
Roboto: {
|
|
25
|
-
normal: 'Roboto-Regular.ttf',
|
|
26
|
-
bold: 'Roboto-Medium.ttf',
|
|
27
|
-
italics: 'Roboto-Italic.ttf',
|
|
28
|
-
bolditalics: 'Roboto-MediumItalic.ttf'
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : void 0;
|
|
33
|
-
if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
|
|
34
|
-
_global.pdfMake.addFontContainer(fontContainer);
|
|
35
|
-
}
|
|
36
|
-
if (typeof module !== 'undefined') {
|
|
37
|
-
module.exports = fontContainer;
|
|
38
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.default = void 0;
|
|
5
|
-
var _base = _interopRequireDefault(require("../base"));
|
|
6
|
-
var _OutputDocumentBrowser = _interopRequireDefault(require("./OutputDocumentBrowser"));
|
|
7
|
-
var _URLBrowserResolver = _interopRequireDefault(require("./URLBrowserResolver"));
|
|
8
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
-
var _configurator = _interopRequireDefault(require("core-js/configurator"));
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
// core-js: Polyfills will be used only if natives completely unavailable.
|
|
12
|
-
(0, _configurator.default)({
|
|
13
|
-
useNative: ['Promise']
|
|
14
|
-
});
|
|
15
|
-
let defaultClientFonts = {
|
|
16
|
-
Roboto: {
|
|
17
|
-
normal: 'Roboto-Regular.ttf',
|
|
18
|
-
bold: 'Roboto-Medium.ttf',
|
|
19
|
-
italics: 'Roboto-Italic.ttf',
|
|
20
|
-
bolditalics: 'Roboto-MediumItalic.ttf'
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
class pdfmake extends _base.default {
|
|
24
|
-
constructor() {
|
|
25
|
-
super();
|
|
26
|
-
this.urlResolver = new _URLBrowserResolver.default(this.virtualfs);
|
|
27
|
-
this.fonts = defaultClientFonts;
|
|
28
|
-
}
|
|
29
|
-
addFontContainer(fontContainer) {
|
|
30
|
-
this.addVirtualFileSystem(fontContainer.vfs);
|
|
31
|
-
this.addFonts(fontContainer.fonts);
|
|
32
|
-
}
|
|
33
|
-
addVirtualFileSystem(vfs) {
|
|
34
|
-
for (let key in vfs) {
|
|
35
|
-
if (vfs.hasOwnProperty(key)) {
|
|
36
|
-
let data;
|
|
37
|
-
let encoding;
|
|
38
|
-
if (typeof vfs[key] === 'object') {
|
|
39
|
-
data = vfs[key].data;
|
|
40
|
-
encoding = vfs[key].encoding || 'base64';
|
|
41
|
-
} else {
|
|
42
|
-
data = vfs[key];
|
|
43
|
-
encoding = 'base64';
|
|
44
|
-
}
|
|
45
|
-
_fs.default.writeFileSync(key, data, encoding);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
_transformToDocument(doc) {
|
|
50
|
-
return new _OutputDocumentBrowser.default(doc);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
var _default = exports.default = new pdfmake();
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const isBrowserSupported = () => {
|
|
4
|
-
if (typeof window === 'undefined' || typeof window.navigator === 'undefined') {
|
|
5
|
-
// Enviroment is not browser.
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
// Internet Explorer 10 and older is not supported.
|
|
10
|
-
return window.navigator.userAgent.indexOf("MSIE") === -1;
|
|
11
|
-
};
|
|
12
|
-
if (!isBrowserSupported()) {
|
|
13
|
-
throw new Error('pdfmake: Internet Explorer 10 and older is not supported. Upgrade to version 11 or use modern browser.');
|
|
14
|
-
}
|
|
15
|
-
module.exports = require('./index').default;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var fs = require('fs');
|
|
4
|
-
var fontContainer = {
|
|
5
|
-
vfs: {
|
|
6
|
-
'data/Courier.afm': {
|
|
7
|
-
data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Courier.afm', 'utf8'),
|
|
8
|
-
encoding: 'utf8'
|
|
9
|
-
},
|
|
10
|
-
'data/Courier-Bold.afm': {
|
|
11
|
-
data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Courier-Bold.afm', 'utf8'),
|
|
12
|
-
encoding: 'utf8'
|
|
13
|
-
},
|
|
14
|
-
'data/Courier-Oblique.afm': {
|
|
15
|
-
data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Courier-Oblique.afm', 'utf8'),
|
|
16
|
-
encoding: 'utf8'
|
|
17
|
-
},
|
|
18
|
-
'data/Courier-BoldOblique.afm': {
|
|
19
|
-
data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Courier-BoldOblique.afm', 'utf8'),
|
|
20
|
-
encoding: 'utf8'
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
fonts: {
|
|
24
|
-
Courier: {
|
|
25
|
-
normal: 'Courier',
|
|
26
|
-
bold: 'Courier-Bold',
|
|
27
|
-
italics: 'Courier-Oblique',
|
|
28
|
-
bolditalics: 'Courier-BoldOblique'
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : void 0;
|
|
33
|
-
if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
|
|
34
|
-
_global.pdfMake.addFontContainer(fontContainer);
|
|
35
|
-
}
|
|
36
|
-
if (typeof module !== 'undefined') {
|
|
37
|
-
module.exports = fontContainer;
|
|
38
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var fs = require('fs');
|
|
4
|
-
var fontContainer = {
|
|
5
|
-
vfs: {
|
|
6
|
-
'data/Helvetica.afm': {
|
|
7
|
-
data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Helvetica.afm', 'utf8'),
|
|
8
|
-
encoding: 'utf8'
|
|
9
|
-
},
|
|
10
|
-
'data/Helvetica-Bold.afm': {
|
|
11
|
-
data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Helvetica-Bold.afm', 'utf8'),
|
|
12
|
-
encoding: 'utf8'
|
|
13
|
-
},
|
|
14
|
-
'data/Helvetica-Oblique.afm': {
|
|
15
|
-
data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Helvetica-Oblique.afm', 'utf8'),
|
|
16
|
-
encoding: 'utf8'
|
|
17
|
-
},
|
|
18
|
-
'data/Helvetica-BoldOblique.afm': {
|
|
19
|
-
data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Helvetica-BoldOblique.afm', 'utf8'),
|
|
20
|
-
encoding: 'utf8'
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
fonts: {
|
|
24
|
-
Helvetica: {
|
|
25
|
-
normal: 'Helvetica',
|
|
26
|
-
bold: 'Helvetica-Bold',
|
|
27
|
-
italics: 'Helvetica-Oblique',
|
|
28
|
-
bolditalics: 'Helvetica-BoldOblique'
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : void 0;
|
|
33
|
-
if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
|
|
34
|
-
_global.pdfMake.addFontContainer(fontContainer);
|
|
35
|
-
}
|
|
36
|
-
if (typeof module !== 'undefined') {
|
|
37
|
-
module.exports = fontContainer;
|
|
38
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var fs = require('fs');
|
|
4
|
-
var fontContainer = {
|
|
5
|
-
vfs: {
|
|
6
|
-
'data/Symbol.afm': {
|
|
7
|
-
data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Symbol.afm', 'utf8'),
|
|
8
|
-
encoding: 'utf8'
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
fonts: {
|
|
12
|
-
Symbol: {
|
|
13
|
-
normal: 'Symbol'
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : void 0;
|
|
18
|
-
if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
|
|
19
|
-
_global.pdfMake.addFontContainer(fontContainer);
|
|
20
|
-
}
|
|
21
|
-
if (typeof module !== 'undefined') {
|
|
22
|
-
module.exports = fontContainer;
|
|
23
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var fs = require('fs');
|
|
4
|
-
var fontContainer = {
|
|
5
|
-
vfs: {
|
|
6
|
-
'data/Times-Roman.afm': {
|
|
7
|
-
data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Times-Roman.afm', 'utf8'),
|
|
8
|
-
encoding: 'utf8'
|
|
9
|
-
},
|
|
10
|
-
'data/Times-Bold.afm': {
|
|
11
|
-
data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Times-Bold.afm', 'utf8'),
|
|
12
|
-
encoding: 'utf8'
|
|
13
|
-
},
|
|
14
|
-
'data/Times-Italic.afm': {
|
|
15
|
-
data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Times-Italic.afm', 'utf8'),
|
|
16
|
-
encoding: 'utf8'
|
|
17
|
-
},
|
|
18
|
-
'data/Times-BoldItalic.afm': {
|
|
19
|
-
data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Times-BoldItalic.afm', 'utf8'),
|
|
20
|
-
encoding: 'utf8'
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
fonts: {
|
|
24
|
-
Times: {
|
|
25
|
-
normal: 'Times-Roman',
|
|
26
|
-
bold: 'Times-Bold',
|
|
27
|
-
italics: 'Times-Italic',
|
|
28
|
-
bolditalics: 'Times-BoldItalic'
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : void 0;
|
|
33
|
-
if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
|
|
34
|
-
_global.pdfMake.addFontContainer(fontContainer);
|
|
35
|
-
}
|
|
36
|
-
if (typeof module !== 'undefined') {
|
|
37
|
-
module.exports = fontContainer;
|
|
38
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var fs = require('fs');
|
|
4
|
-
var fontContainer = {
|
|
5
|
-
vfs: {
|
|
6
|
-
'data/ZapfDingbats.afm': {
|
|
7
|
-
data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/ZapfDingbats.afm', 'utf8'),
|
|
8
|
-
encoding: 'utf8'
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
fonts: {
|
|
12
|
-
ZapfDingbats: {
|
|
13
|
-
normal: 'ZapfDingbats'
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : void 0;
|
|
18
|
-
if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
|
|
19
|
-
_global.pdfMake.addFontContainer(fontContainer);
|
|
20
|
-
}
|
|
21
|
-
if (typeof module !== 'undefined') {
|
|
22
|
-
module.exports = fontContainer;
|
|
23
|
-
}
|
package/js/columnCalculator.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.default = void 0;
|
|
5
|
-
var _variableType = require("./helpers/variableType");
|
|
6
|
-
function buildColumnWidths(columns, availableWidth) {
|
|
7
|
-
let autoColumns = [];
|
|
8
|
-
let autoMin = 0;
|
|
9
|
-
let autoMax = 0;
|
|
10
|
-
let starColumns = [];
|
|
11
|
-
let starMaxMin = 0;
|
|
12
|
-
let starMaxMax = 0;
|
|
13
|
-
let fixedColumns = [];
|
|
14
|
-
let initial_availableWidth = availableWidth;
|
|
15
|
-
columns.forEach(column => {
|
|
16
|
-
if (isAutoColumn(column)) {
|
|
17
|
-
autoColumns.push(column);
|
|
18
|
-
autoMin += column._minWidth;
|
|
19
|
-
autoMax += column._maxWidth;
|
|
20
|
-
} else if (isStarColumn(column)) {
|
|
21
|
-
starColumns.push(column);
|
|
22
|
-
starMaxMin = Math.max(starMaxMin, column._minWidth);
|
|
23
|
-
starMaxMax = Math.max(starMaxMax, column._maxWidth);
|
|
24
|
-
} else {
|
|
25
|
-
fixedColumns.push(column);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
fixedColumns.forEach(col => {
|
|
29
|
-
// width specified as %
|
|
30
|
-
if ((0, _variableType.isString)(col.width) && /\d+%/.test(col.width)) {
|
|
31
|
-
col.width = parseFloat(col.width) * initial_availableWidth / 100;
|
|
32
|
-
}
|
|
33
|
-
if (col.width < col._minWidth && col.elasticWidth) {
|
|
34
|
-
col._calcWidth = col._minWidth;
|
|
35
|
-
} else {
|
|
36
|
-
col._calcWidth = col.width;
|
|
37
|
-
}
|
|
38
|
-
availableWidth -= col._calcWidth;
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// http://www.freesoft.org/CIE/RFC/1942/18.htm
|
|
42
|
-
// http://www.w3.org/TR/CSS2/tables.html#width-layout
|
|
43
|
-
// http://dev.w3.org/csswg/css3-tables-algorithms/Overview.src.htm
|
|
44
|
-
let minW = autoMin + starMaxMin * starColumns.length;
|
|
45
|
-
let maxW = autoMax + starMaxMax * starColumns.length;
|
|
46
|
-
if (minW >= availableWidth) {
|
|
47
|
-
// case 1 - there's no way to fit all columns within available width
|
|
48
|
-
// that's actually pretty bad situation with PDF as we have no horizontal scroll
|
|
49
|
-
// no easy workaround (unless we decide, in the future, to split single words)
|
|
50
|
-
// currently we simply use minWidths for all columns
|
|
51
|
-
autoColumns.forEach(col => {
|
|
52
|
-
col._calcWidth = col._minWidth;
|
|
53
|
-
});
|
|
54
|
-
starColumns.forEach(col => {
|
|
55
|
-
col._calcWidth = starMaxMin; // starMaxMin already contains padding
|
|
56
|
-
});
|
|
57
|
-
} else {
|
|
58
|
-
if (maxW < availableWidth) {
|
|
59
|
-
// case 2 - we can fit rest of the table within available space
|
|
60
|
-
autoColumns.forEach(col => {
|
|
61
|
-
col._calcWidth = col._maxWidth;
|
|
62
|
-
availableWidth -= col._calcWidth;
|
|
63
|
-
});
|
|
64
|
-
} else {
|
|
65
|
-
// maxW is too large, but minW fits within available width
|
|
66
|
-
let W = availableWidth - minW;
|
|
67
|
-
let D = maxW - minW;
|
|
68
|
-
autoColumns.forEach(col => {
|
|
69
|
-
let d = col._maxWidth - col._minWidth;
|
|
70
|
-
col._calcWidth = col._minWidth + d * W / D;
|
|
71
|
-
availableWidth -= col._calcWidth;
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
if (starColumns.length > 0) {
|
|
75
|
-
let starSize = availableWidth / starColumns.length;
|
|
76
|
-
starColumns.forEach(col => {
|
|
77
|
-
col._calcWidth = starSize;
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function isAutoColumn(column) {
|
|
83
|
-
return column.width === 'auto';
|
|
84
|
-
}
|
|
85
|
-
function isStarColumn(column) {
|
|
86
|
-
return column.width === null || column.width === undefined || column.width === '*' || column.width === 'star';
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
//TODO: refactor and reuse in measureTable
|
|
90
|
-
function measureMinMax(columns) {
|
|
91
|
-
let result = {
|
|
92
|
-
min: 0,
|
|
93
|
-
max: 0
|
|
94
|
-
};
|
|
95
|
-
let maxStar = {
|
|
96
|
-
min: 0,
|
|
97
|
-
max: 0
|
|
98
|
-
};
|
|
99
|
-
let starCount = 0;
|
|
100
|
-
for (let i = 0, l = columns.length; i < l; i++) {
|
|
101
|
-
let c = columns[i];
|
|
102
|
-
if (isStarColumn(c)) {
|
|
103
|
-
maxStar.min = Math.max(maxStar.min, c._minWidth);
|
|
104
|
-
maxStar.max = Math.max(maxStar.max, c._maxWidth);
|
|
105
|
-
starCount++;
|
|
106
|
-
} else if (isAutoColumn(c)) {
|
|
107
|
-
result.min += c._minWidth;
|
|
108
|
-
result.max += c._maxWidth;
|
|
109
|
-
} else {
|
|
110
|
-
result.min += c.width !== undefined && c.width || c._minWidth;
|
|
111
|
-
result.max += c.width !== undefined && c.width || c._maxWidth;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
if (starCount) {
|
|
115
|
-
result.min += starCount * maxStar.min;
|
|
116
|
-
result.max += starCount * maxStar.max;
|
|
117
|
-
}
|
|
118
|
-
return result;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Calculates column widths
|
|
123
|
-
*/
|
|
124
|
-
var _default = exports.default = {
|
|
125
|
-
buildColumnWidths: buildColumnWidths,
|
|
126
|
-
measureMinMax: measureMinMax,
|
|
127
|
-
isAutoColumn: isAutoColumn,
|
|
128
|
-
isStarColumn: isStarColumn
|
|
129
|
-
};
|
package/js/helpers/node.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.getNodeId = getNodeId;
|
|
5
|
-
exports.getNodeMargin = getNodeMargin;
|
|
6
|
-
exports.stringifyNode = stringifyNode;
|
|
7
|
-
var _variableType = require("./variableType");
|
|
8
|
-
function fontStringify(key, val) {
|
|
9
|
-
if (key === 'font') {
|
|
10
|
-
return 'font';
|
|
11
|
-
}
|
|
12
|
-
return val;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Convert node to readable string
|
|
17
|
-
*
|
|
18
|
-
* @param {object} node
|
|
19
|
-
* @returns {string}
|
|
20
|
-
*/
|
|
21
|
-
function stringifyNode(node) {
|
|
22
|
-
return JSON.stringify(node, fontStringify);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @param {object} node
|
|
27
|
-
* @returns {?string}
|
|
28
|
-
*/
|
|
29
|
-
function getNodeId(node) {
|
|
30
|
-
if (node.id) {
|
|
31
|
-
return node.id;
|
|
32
|
-
}
|
|
33
|
-
if (Array.isArray(node.text)) {
|
|
34
|
-
for (let n of node.text) {
|
|
35
|
-
let nodeId = getNodeId(n);
|
|
36
|
-
if (nodeId) {
|
|
37
|
-
return nodeId;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @param {object} node
|
|
46
|
-
* @param {object} styleStack object is instance of PDFDocument
|
|
47
|
-
* @returns {?Array}
|
|
48
|
-
*/
|
|
49
|
-
function getNodeMargin(node, styleStack) {
|
|
50
|
-
function processSingleMargins(node, currentMargin) {
|
|
51
|
-
if (node.marginLeft || node.marginTop || node.marginRight || node.marginBottom) {
|
|
52
|
-
return [node.marginLeft || currentMargin[0] || 0, node.marginTop || currentMargin[1] || 0, node.marginRight || currentMargin[2] || 0, node.marginBottom || currentMargin[3] || 0];
|
|
53
|
-
}
|
|
54
|
-
return currentMargin;
|
|
55
|
-
}
|
|
56
|
-
function flattenStyleArray(styleArray, styleStack) {
|
|
57
|
-
let flattenedStyles = {};
|
|
58
|
-
for (let i = styleArray.length - 1; i >= 0; i--) {
|
|
59
|
-
let styleName = styleArray[i];
|
|
60
|
-
let style = styleStack.styleDictionary[styleName];
|
|
61
|
-
for (let key in style) {
|
|
62
|
-
if (style.hasOwnProperty(key)) {
|
|
63
|
-
flattenedStyles[key] = style[key];
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return flattenedStyles;
|
|
68
|
-
}
|
|
69
|
-
function convertMargin(margin) {
|
|
70
|
-
if ((0, _variableType.isNumber)(margin)) {
|
|
71
|
-
margin = [margin, margin, margin, margin];
|
|
72
|
-
} else if (Array.isArray(margin)) {
|
|
73
|
-
if (margin.length === 2) {
|
|
74
|
-
margin = [margin[0], margin[1], margin[0], margin[1]];
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return margin;
|
|
78
|
-
}
|
|
79
|
-
let margin = [undefined, undefined, undefined, undefined];
|
|
80
|
-
if (node.style) {
|
|
81
|
-
let styleArray = Array.isArray(node.style) ? node.style : [node.style];
|
|
82
|
-
let flattenedStyleArray = flattenStyleArray(styleArray, styleStack);
|
|
83
|
-
if (flattenedStyleArray) {
|
|
84
|
-
margin = processSingleMargins(flattenedStyleArray, margin);
|
|
85
|
-
}
|
|
86
|
-
if (flattenedStyleArray.margin) {
|
|
87
|
-
margin = convertMargin(flattenedStyleArray.margin);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
margin = processSingleMargins(node, margin);
|
|
91
|
-
if (node.margin) {
|
|
92
|
-
margin = convertMargin(node.margin);
|
|
93
|
-
}
|
|
94
|
-
if (margin[0] === undefined && margin[1] === undefined && margin[2] === undefined && margin[3] === undefined) {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
return margin;
|
|
98
|
-
}
|
package/js/helpers/tools.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.offsetVector = offsetVector;
|
|
5
|
-
exports.pack = pack;
|
|
6
|
-
function pack(...args) {
|
|
7
|
-
let result = {};
|
|
8
|
-
for (let i = 0, l = args.length; i < l; i++) {
|
|
9
|
-
let obj = args[i];
|
|
10
|
-
if (obj) {
|
|
11
|
-
for (let key in obj) {
|
|
12
|
-
if (obj.hasOwnProperty(key)) {
|
|
13
|
-
result[key] = obj[key];
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
function offsetVector(vector, x, y) {
|
|
21
|
-
switch (vector.type) {
|
|
22
|
-
case 'ellipse':
|
|
23
|
-
case 'rect':
|
|
24
|
-
vector.x += x;
|
|
25
|
-
vector.y += y;
|
|
26
|
-
break;
|
|
27
|
-
case 'line':
|
|
28
|
-
vector.x1 += x;
|
|
29
|
-
vector.x2 += x;
|
|
30
|
-
vector.y1 += y;
|
|
31
|
-
vector.y2 += y;
|
|
32
|
-
break;
|
|
33
|
-
case 'polyline':
|
|
34
|
-
for (let i = 0, l = vector.points.length; i < l; i++) {
|
|
35
|
-
vector.points[i].x += x;
|
|
36
|
-
vector.points[i].y += y;
|
|
37
|
-
}
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.isEmptyObject = isEmptyObject;
|
|
5
|
-
exports.isNumber = isNumber;
|
|
6
|
-
exports.isObject = isObject;
|
|
7
|
-
exports.isString = isString;
|
|
8
|
-
exports.isValue = isValue;
|
|
9
|
-
/**
|
|
10
|
-
* @param {any} variable
|
|
11
|
-
* @returns {boolean}
|
|
12
|
-
*/
|
|
13
|
-
function isString(variable) {
|
|
14
|
-
return typeof variable === 'string' || variable instanceof String;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @param {any} variable
|
|
19
|
-
* @returns {boolean}
|
|
20
|
-
*/
|
|
21
|
-
function isNumber(variable) {
|
|
22
|
-
return typeof variable === 'number' || variable instanceof Number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @param {any} variable
|
|
27
|
-
* @returns {boolean}
|
|
28
|
-
*/
|
|
29
|
-
function isObject(variable) {
|
|
30
|
-
return variable !== null && !Array.isArray(variable) && !isString(variable) && !isNumber(variable) && typeof variable === 'object';
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @param {any} variable
|
|
35
|
-
* @returns {boolean}
|
|
36
|
-
*/
|
|
37
|
-
function isEmptyObject(variable) {
|
|
38
|
-
return isObject(variable) && Object.keys(variable).length === 0;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @param {any} variable
|
|
43
|
-
* @returns {boolean}
|
|
44
|
-
*/
|
|
45
|
-
function isValue(variable) {
|
|
46
|
-
return variable !== undefined && variable !== null;
|
|
47
|
-
}
|
package/js/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const pdfmakeBase = require('./base').default;
|
|
4
|
-
const OutputDocumentServer = require('./OutputDocumentServer').default;
|
|
5
|
-
const URLResolver = require('./URLResolver').default;
|
|
6
|
-
class pdfmake extends pdfmakeBase {
|
|
7
|
-
constructor() {
|
|
8
|
-
super();
|
|
9
|
-
this.urlResolver = new URLResolver(this.virtualfs);
|
|
10
|
-
}
|
|
11
|
-
_transformToDocument(doc) {
|
|
12
|
-
return new OutputDocumentServer(doc);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
module.exports = new pdfmake();
|