@flowaccount/pdfmake 1.0.6-staging.3 → 1.0.6
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/LICENSE +21 -21
- package/README.md +297 -297
- package/build/pdfmake.js +56029 -55532
- package/build/pdfmake.min.js +2 -2
- package/build/pdfmake.min.js.map +1 -1
- package/build/vfs_fonts.js +6 -6
- package/package.json +110 -110
- package/src/3rd-party/svg-to-pdfkit.js +3 -3
- package/src/browser-extensions/URLBrowserResolver.js +96 -96
- package/src/browser-extensions/pdfMake.js +361 -361
- package/src/browser-extensions/tokenizer-shim.js +15 -15
- package/src/browser-extensions/virtual-fs.js +55 -55
- package/src/columnCalculator.js +157 -157
- package/src/docMeasure.js +831 -831
- package/src/docPreprocessor.js +277 -277
- package/src/documentContext.js +383 -383
- package/src/elementWriter.js +442 -442
- package/src/fontProvider.js +68 -68
- package/src/helpers.js +138 -138
- package/src/imageMeasure.js +70 -70
- package/src/layoutBuilder.js +2012 -1993
- package/src/line.js +91 -91
- package/src/pageElementWriter.js +362 -362
- package/src/pdfKitEngine.js +21 -21
- package/src/printer.js +1191 -1191
- package/src/qrEnc.js +790 -790
- package/src/standardPageSizes.js +54 -54
- package/src/styleContextStack.js +138 -138
- package/src/svgMeasure.js +70 -70
- package/src/tableProcessor.js +791 -791
- package/src/textDecorator.js +157 -157
- package/src/textTools.js +442 -442
- package/src/traversalTracker.js +47 -47
package/src/line.js
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Creates an instance of Line
|
|
5
|
-
*
|
|
6
|
-
* @constructor
|
|
7
|
-
* @this {Line}
|
|
8
|
-
* @param {Number} Maximum width this line can have
|
|
9
|
-
*/
|
|
10
|
-
function Line(maxWidth) {
|
|
11
|
-
this.maxWidth = maxWidth;
|
|
12
|
-
this.leadingCut = 0;
|
|
13
|
-
this.trailingCut = 0;
|
|
14
|
-
this.inlineWidths = 0;
|
|
15
|
-
this.inlines = [];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
Line.prototype.getAscenderHeight = function () {
|
|
19
|
-
var y = 0;
|
|
20
|
-
|
|
21
|
-
this.inlines.forEach(function (inline) {
|
|
22
|
-
y = Math.max(y, inline.font.ascender / 1000 * inline.fontSize);
|
|
23
|
-
});
|
|
24
|
-
return y;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
Line.prototype.hasEnoughSpaceForInline = function (inline, nextInlines) {
|
|
28
|
-
nextInlines = nextInlines || [];
|
|
29
|
-
|
|
30
|
-
if (this.inlines.length === 0) {
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
if (this.newLineForced) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
var inlineWidth = inline.width;
|
|
38
|
-
var inlineTrailingCut = inline.trailingCut || 0;
|
|
39
|
-
if (inline.noNewLine) {
|
|
40
|
-
for (var i = 0, l = nextInlines.length; i < l; i++) {
|
|
41
|
-
var nextInline = nextInlines[i];
|
|
42
|
-
inlineWidth += nextInline.width;
|
|
43
|
-
inlineTrailingCut += nextInline.trailingCut || 0;
|
|
44
|
-
if (!nextInline.noNewLine) {
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return (this.inlineWidths + inlineWidth - this.leadingCut - inlineTrailingCut) <= this.maxWidth;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
Line.prototype.addInline = function (inline) {
|
|
54
|
-
if (this.inlines.length === 0) {
|
|
55
|
-
this.leadingCut = inline.leadingCut || 0;
|
|
56
|
-
}
|
|
57
|
-
this.trailingCut = inline.trailingCut || 0;
|
|
58
|
-
|
|
59
|
-
inline.x = this.inlineWidths - this.leadingCut;
|
|
60
|
-
|
|
61
|
-
this.inlines.push(inline);
|
|
62
|
-
this.inlineWidths += inline.width;
|
|
63
|
-
|
|
64
|
-
if (inline.lineEnd) {
|
|
65
|
-
this.newLineForced = true;
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
Line.prototype.getWidth = function () {
|
|
70
|
-
return this.inlineWidths - this.leadingCut - this.trailingCut;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
Line.prototype.getAvailableWidth = function () {
|
|
74
|
-
return this.maxWidth - this.getWidth();
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Returns line height
|
|
79
|
-
* @return {Number}
|
|
80
|
-
*/
|
|
81
|
-
Line.prototype.getHeight = function () {
|
|
82
|
-
var max = 0;
|
|
83
|
-
|
|
84
|
-
this.inlines.forEach(function (item) {
|
|
85
|
-
max = Math.max(max, item.height || 0);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
return max;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
module.exports = Line;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates an instance of Line
|
|
5
|
+
*
|
|
6
|
+
* @constructor
|
|
7
|
+
* @this {Line}
|
|
8
|
+
* @param {Number} Maximum width this line can have
|
|
9
|
+
*/
|
|
10
|
+
function Line(maxWidth) {
|
|
11
|
+
this.maxWidth = maxWidth;
|
|
12
|
+
this.leadingCut = 0;
|
|
13
|
+
this.trailingCut = 0;
|
|
14
|
+
this.inlineWidths = 0;
|
|
15
|
+
this.inlines = [];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Line.prototype.getAscenderHeight = function () {
|
|
19
|
+
var y = 0;
|
|
20
|
+
|
|
21
|
+
this.inlines.forEach(function (inline) {
|
|
22
|
+
y = Math.max(y, inline.font.ascender / 1000 * inline.fontSize);
|
|
23
|
+
});
|
|
24
|
+
return y;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
Line.prototype.hasEnoughSpaceForInline = function (inline, nextInlines) {
|
|
28
|
+
nextInlines = nextInlines || [];
|
|
29
|
+
|
|
30
|
+
if (this.inlines.length === 0) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
if (this.newLineForced) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var inlineWidth = inline.width;
|
|
38
|
+
var inlineTrailingCut = inline.trailingCut || 0;
|
|
39
|
+
if (inline.noNewLine) {
|
|
40
|
+
for (var i = 0, l = nextInlines.length; i < l; i++) {
|
|
41
|
+
var nextInline = nextInlines[i];
|
|
42
|
+
inlineWidth += nextInline.width;
|
|
43
|
+
inlineTrailingCut += nextInline.trailingCut || 0;
|
|
44
|
+
if (!nextInline.noNewLine) {
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return (this.inlineWidths + inlineWidth - this.leadingCut - inlineTrailingCut) <= this.maxWidth;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
Line.prototype.addInline = function (inline) {
|
|
54
|
+
if (this.inlines.length === 0) {
|
|
55
|
+
this.leadingCut = inline.leadingCut || 0;
|
|
56
|
+
}
|
|
57
|
+
this.trailingCut = inline.trailingCut || 0;
|
|
58
|
+
|
|
59
|
+
inline.x = this.inlineWidths - this.leadingCut;
|
|
60
|
+
|
|
61
|
+
this.inlines.push(inline);
|
|
62
|
+
this.inlineWidths += inline.width;
|
|
63
|
+
|
|
64
|
+
if (inline.lineEnd) {
|
|
65
|
+
this.newLineForced = true;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
Line.prototype.getWidth = function () {
|
|
70
|
+
return this.inlineWidths - this.leadingCut - this.trailingCut;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
Line.prototype.getAvailableWidth = function () {
|
|
74
|
+
return this.maxWidth - this.getWidth();
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Returns line height
|
|
79
|
+
* @return {Number}
|
|
80
|
+
*/
|
|
81
|
+
Line.prototype.getHeight = function () {
|
|
82
|
+
var max = 0;
|
|
83
|
+
|
|
84
|
+
this.inlines.forEach(function (item) {
|
|
85
|
+
max = Math.max(max, item.height || 0);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return max;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
module.exports = Line;
|