pdfmake 0.3.0-beta.3 → 0.3.0-beta.4
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 +5 -0
- package/build/pdfmake.js +2122 -8531
- 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 +4 -13
- 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/3rd-party/svg-to-pdfkit/LICENSE +9 -9
package/js/TableProcessor.js
CHANGED
|
@@ -2,18 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.default = void 0;
|
|
5
|
-
|
|
6
5
|
var _columnCalculator = _interopRequireDefault(require("./columnCalculator"));
|
|
7
|
-
|
|
8
6
|
var _variableType = require("./helpers/variableType");
|
|
9
|
-
|
|
10
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
8
|
class TableProcessor {
|
|
13
9
|
constructor(tableNode) {
|
|
14
10
|
this.tableNode = tableNode;
|
|
15
11
|
}
|
|
16
|
-
|
|
17
12
|
beginTable(writer) {
|
|
18
13
|
const getTableInnerContentWidth = () => {
|
|
19
14
|
let width = 0;
|
|
@@ -22,7 +17,6 @@ class TableProcessor {
|
|
|
22
17
|
});
|
|
23
18
|
return width;
|
|
24
19
|
};
|
|
25
|
-
|
|
26
20
|
const prepareRowSpanData = () => {
|
|
27
21
|
let rsd = [];
|
|
28
22
|
let x = 0;
|
|
@@ -31,7 +25,6 @@ class TableProcessor {
|
|
|
31
25
|
left: 0,
|
|
32
26
|
rowSpan: 0
|
|
33
27
|
});
|
|
34
|
-
|
|
35
28
|
for (let i = 0, l = this.tableNode.table.body[0].length; i < l; i++) {
|
|
36
29
|
let paddings = this.layout.paddingLeft(i, this.tableNode) + this.layout.paddingRight(i, this.tableNode);
|
|
37
30
|
let lBorder = this.layout.vLineWidth(i, this.tableNode);
|
|
@@ -44,86 +37,76 @@ class TableProcessor {
|
|
|
44
37
|
width: 0
|
|
45
38
|
});
|
|
46
39
|
}
|
|
47
|
-
|
|
48
40
|
return rsd;
|
|
49
|
-
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Iterate through all cells. If the current cell is the start of a
|
|
50
44
|
// rowSpan/colSpan, update the border property of the cells on its
|
|
51
45
|
// bottom/right accordingly. This is needed since each iteration of the
|
|
52
46
|
// line-drawing loops draws lines for a single cell, not for an entire
|
|
53
47
|
// rowSpan/colSpan.
|
|
54
|
-
|
|
55
|
-
|
|
56
48
|
const prepareCellBorders = body => {
|
|
57
49
|
for (let rowIndex = 0; rowIndex < body.length; rowIndex++) {
|
|
58
50
|
let row = body[rowIndex];
|
|
59
|
-
|
|
60
51
|
for (let colIndex = 0; colIndex < row.length; colIndex++) {
|
|
61
52
|
let cell = row[colIndex];
|
|
62
|
-
|
|
63
53
|
if (cell.border) {
|
|
64
54
|
let rowSpan = cell.rowSpan || 1;
|
|
65
55
|
let colSpan = cell.colSpan || 1;
|
|
66
|
-
|
|
67
56
|
for (let rowOffset = 0; rowOffset < rowSpan; rowOffset++) {
|
|
68
57
|
// set left border
|
|
69
58
|
if (cell.border[0] !== undefined && rowOffset > 0) {
|
|
70
59
|
setBorder(rowIndex + rowOffset, colIndex, 0, cell.border[0]);
|
|
71
|
-
}
|
|
72
|
-
|
|
60
|
+
}
|
|
73
61
|
|
|
62
|
+
// set right border
|
|
74
63
|
if (cell.border[2] !== undefined) {
|
|
75
64
|
setBorder(rowIndex + rowOffset, colIndex + colSpan - 1, 2, cell.border[2]);
|
|
76
65
|
}
|
|
77
66
|
}
|
|
78
|
-
|
|
79
67
|
for (let colOffset = 0; colOffset < colSpan; colOffset++) {
|
|
80
68
|
// set top border
|
|
81
69
|
if (cell.border[1] !== undefined && colOffset > 0) {
|
|
82
70
|
setBorder(rowIndex, colIndex + colOffset, 1, cell.border[1]);
|
|
83
|
-
}
|
|
84
|
-
|
|
71
|
+
}
|
|
85
72
|
|
|
73
|
+
// set bottom border
|
|
86
74
|
if (cell.border[3] !== undefined) {
|
|
87
75
|
setBorder(rowIndex + rowSpan - 1, colIndex + colOffset, 3, cell.border[3]);
|
|
88
76
|
}
|
|
89
77
|
}
|
|
90
78
|
}
|
|
91
79
|
}
|
|
92
|
-
}
|
|
93
|
-
|
|
80
|
+
}
|
|
94
81
|
|
|
82
|
+
// helper function to set the border for a given cell
|
|
95
83
|
function setBorder(rowIndex, colIndex, borderIndex, borderValue) {
|
|
96
84
|
let cell = body[rowIndex][colIndex];
|
|
97
85
|
cell.border = cell.border || {};
|
|
98
86
|
cell.border[borderIndex] = borderValue;
|
|
99
87
|
}
|
|
100
88
|
};
|
|
101
|
-
|
|
102
89
|
let tableNode;
|
|
103
90
|
let availableWidth;
|
|
104
91
|
tableNode = this.tableNode;
|
|
105
92
|
this.offsets = tableNode._offsets;
|
|
106
93
|
this.layout = tableNode._layout;
|
|
107
94
|
availableWidth = writer.context().availableWidth - this.offsets.total;
|
|
108
|
-
|
|
109
95
|
_columnCalculator.default.buildColumnWidths(tableNode.table.widths, availableWidth);
|
|
110
|
-
|
|
111
96
|
this.tableWidth = tableNode._offsets.total + getTableInnerContentWidth();
|
|
112
97
|
this.rowSpanData = prepareRowSpanData();
|
|
113
98
|
this.cleanUpRepeatables = false;
|
|
114
99
|
this.headerRows = tableNode.table.headerRows || 0;
|
|
115
100
|
this.rowsWithoutPageBreak = this.headerRows + (tableNode.table.keepWithHeaderRows || 0);
|
|
116
101
|
this.dontBreakRows = tableNode.table.dontBreakRows || false;
|
|
117
|
-
|
|
118
102
|
if (this.rowsWithoutPageBreak) {
|
|
119
103
|
writer.beginUnbreakableBlock();
|
|
120
|
-
}
|
|
121
|
-
|
|
104
|
+
}
|
|
122
105
|
|
|
106
|
+
// update the border properties of all cells before drawing any lines
|
|
123
107
|
prepareCellBorders(this.tableNode.table.body);
|
|
124
108
|
this.drawHorizontalLine(0, writer);
|
|
125
109
|
}
|
|
126
|
-
|
|
127
110
|
onRowBreak(rowIndex, writer) {
|
|
128
111
|
return () => {
|
|
129
112
|
let offset = this.rowPaddingTop + (!this.headerRows ? this.topLineWidth : 0);
|
|
@@ -131,7 +114,6 @@ class TableProcessor {
|
|
|
131
114
|
writer.context().moveDown(offset);
|
|
132
115
|
};
|
|
133
116
|
}
|
|
134
|
-
|
|
135
117
|
beginRow(rowIndex, writer) {
|
|
136
118
|
this.topLineWidth = this.layout.hLineWidth(rowIndex, this.tableNode);
|
|
137
119
|
this.rowPaddingTop = this.layout.paddingTop(rowIndex, this.tableNode);
|
|
@@ -139,116 +121,97 @@ class TableProcessor {
|
|
|
139
121
|
this.rowPaddingBottom = this.layout.paddingBottom(rowIndex, this.tableNode);
|
|
140
122
|
this.rowCallback = this.onRowBreak(rowIndex, writer);
|
|
141
123
|
writer.addListener('pageChanged', this.rowCallback);
|
|
142
|
-
|
|
143
124
|
if (this.dontBreakRows) {
|
|
144
125
|
writer.beginUnbreakableBlock();
|
|
145
126
|
}
|
|
146
|
-
|
|
147
127
|
this.rowTopY = writer.context().y;
|
|
148
128
|
this.reservedAtBottom = this.bottomLineWidth + this.rowPaddingBottom;
|
|
149
129
|
writer.context().availableHeight -= this.reservedAtBottom;
|
|
150
130
|
writer.context().moveDown(this.rowPaddingTop);
|
|
151
131
|
}
|
|
152
|
-
|
|
153
132
|
drawHorizontalLine(lineIndex, writer, overrideY) {
|
|
154
133
|
let lineWidth = this.layout.hLineWidth(lineIndex, this.tableNode);
|
|
155
|
-
|
|
156
134
|
if (lineWidth) {
|
|
157
135
|
let style = this.layout.hLineStyle(lineIndex, this.tableNode);
|
|
158
136
|
let dash;
|
|
159
|
-
|
|
160
137
|
if (style && style.dash) {
|
|
161
138
|
dash = style.dash;
|
|
162
139
|
}
|
|
163
|
-
|
|
164
140
|
let offset = lineWidth / 2;
|
|
165
141
|
let currentLine = null;
|
|
166
142
|
let body = this.tableNode.table.body;
|
|
167
143
|
let cellAbove;
|
|
168
144
|
let currentCell;
|
|
169
145
|
let rowCellAbove;
|
|
170
|
-
|
|
171
146
|
for (let i = 0, l = this.rowSpanData.length; i < l; i++) {
|
|
172
147
|
let data = this.rowSpanData[i];
|
|
173
148
|
let shouldDrawLine = !data.rowSpan;
|
|
174
|
-
let borderColor = null;
|
|
175
|
-
// row above requires a bottom border
|
|
149
|
+
let borderColor = null;
|
|
176
150
|
|
|
151
|
+
// draw only if the current cell requires a top border or the cell in the
|
|
152
|
+
// row above requires a bottom border
|
|
177
153
|
if (shouldDrawLine && i < l - 1) {
|
|
178
154
|
var topBorder = false,
|
|
179
|
-
|
|
180
|
-
|
|
155
|
+
bottomBorder = false,
|
|
156
|
+
rowBottomBorder = false;
|
|
181
157
|
|
|
158
|
+
// the cell in the row above
|
|
182
159
|
if (lineIndex > 0) {
|
|
183
160
|
cellAbove = body[lineIndex - 1][i];
|
|
184
161
|
bottomBorder = cellAbove.border ? cellAbove.border[3] : this.layout.defaultBorder;
|
|
185
|
-
|
|
186
162
|
if (bottomBorder && cellAbove.borderColor) {
|
|
187
163
|
borderColor = cellAbove.borderColor[3];
|
|
188
164
|
}
|
|
189
|
-
}
|
|
190
|
-
|
|
165
|
+
}
|
|
191
166
|
|
|
167
|
+
// the current cell
|
|
192
168
|
if (lineIndex < body.length) {
|
|
193
169
|
currentCell = body[lineIndex][i];
|
|
194
170
|
topBorder = currentCell.border ? currentCell.border[1] : this.layout.defaultBorder;
|
|
195
|
-
|
|
196
171
|
if (topBorder && borderColor == null && currentCell.borderColor) {
|
|
197
172
|
borderColor = currentCell.borderColor[1];
|
|
198
173
|
}
|
|
199
174
|
}
|
|
200
|
-
|
|
201
175
|
shouldDrawLine = topBorder || bottomBorder;
|
|
202
176
|
}
|
|
203
|
-
|
|
204
177
|
if (cellAbove && cellAbove._rowSpanCurrentOffset) {
|
|
205
178
|
rowCellAbove = body[lineIndex - 1 - cellAbove._rowSpanCurrentOffset][i];
|
|
206
179
|
rowBottomBorder = rowCellAbove && rowCellAbove.border ? rowCellAbove.border[3] : this.layout.defaultBorder;
|
|
207
|
-
|
|
208
180
|
if (rowBottomBorder && rowCellAbove && rowCellAbove.borderColor) {
|
|
209
181
|
borderColor = rowCellAbove.borderColor[3];
|
|
210
182
|
}
|
|
211
183
|
}
|
|
212
|
-
|
|
213
184
|
if (borderColor == null) {
|
|
214
185
|
borderColor = typeof this.layout.hLineColor === 'function' ? this.layout.hLineColor(lineIndex, this.tableNode, i) : this.layout.hLineColor;
|
|
215
186
|
}
|
|
216
|
-
|
|
217
187
|
if (!currentLine && shouldDrawLine) {
|
|
218
188
|
currentLine = {
|
|
219
189
|
left: data.left,
|
|
220
190
|
width: 0
|
|
221
191
|
};
|
|
222
192
|
}
|
|
223
|
-
|
|
224
193
|
if (shouldDrawLine) {
|
|
225
194
|
let colSpanIndex = 0;
|
|
226
|
-
|
|
227
195
|
if (rowCellAbove && rowCellAbove.colSpan && rowBottomBorder) {
|
|
228
196
|
while (rowCellAbove.colSpan > colSpanIndex) {
|
|
229
197
|
currentLine.width += this.rowSpanData[i + colSpanIndex++].width || 0;
|
|
230
198
|
}
|
|
231
|
-
|
|
232
199
|
i += colSpanIndex - 1;
|
|
233
200
|
} else if (cellAbove && cellAbove.colSpan && bottomBorder) {
|
|
234
201
|
while (cellAbove.colSpan > colSpanIndex) {
|
|
235
202
|
currentLine.width += this.rowSpanData[i + colSpanIndex++].width || 0;
|
|
236
203
|
}
|
|
237
|
-
|
|
238
204
|
i += colSpanIndex - 1;
|
|
239
205
|
} else if (currentCell && currentCell.colSpan && topBorder) {
|
|
240
206
|
while (currentCell.colSpan > colSpanIndex) {
|
|
241
207
|
currentLine.width += this.rowSpanData[i + colSpanIndex++].width || 0;
|
|
242
208
|
}
|
|
243
|
-
|
|
244
209
|
i += colSpanIndex - 1;
|
|
245
210
|
} else {
|
|
246
211
|
currentLine.width += this.rowSpanData[i].width || 0;
|
|
247
212
|
}
|
|
248
213
|
}
|
|
249
|
-
|
|
250
214
|
let y = (overrideY || 0) + offset;
|
|
251
|
-
|
|
252
215
|
if (shouldDrawLine) {
|
|
253
216
|
if (currentLine && currentLine.width) {
|
|
254
217
|
writer.addVector({
|
|
@@ -269,75 +232,62 @@ class TableProcessor {
|
|
|
269
232
|
}
|
|
270
233
|
}
|
|
271
234
|
}
|
|
272
|
-
|
|
273
235
|
writer.context().moveDown(lineWidth);
|
|
274
236
|
}
|
|
275
237
|
}
|
|
276
|
-
|
|
277
238
|
drawVerticalLine(x, y0, y1, vLineColIndex, writer, vLineRowIndex, beforeVLineColIndex) {
|
|
278
239
|
let width = this.layout.vLineWidth(vLineColIndex, this.tableNode);
|
|
279
|
-
|
|
280
240
|
if (width === 0) {
|
|
281
241
|
return;
|
|
282
242
|
}
|
|
283
|
-
|
|
284
243
|
let style = this.layout.vLineStyle(vLineColIndex, this.tableNode);
|
|
285
244
|
let dash;
|
|
286
|
-
|
|
287
245
|
if (style && style.dash) {
|
|
288
246
|
dash = style.dash;
|
|
289
247
|
}
|
|
290
|
-
|
|
291
248
|
let body = this.tableNode.table.body;
|
|
292
249
|
let cellBefore;
|
|
293
250
|
let currentCell;
|
|
294
|
-
let borderColor;
|
|
251
|
+
let borderColor;
|
|
295
252
|
|
|
253
|
+
// the cell in the col before
|
|
296
254
|
if (vLineColIndex > 0) {
|
|
297
255
|
cellBefore = body[vLineRowIndex][beforeVLineColIndex];
|
|
298
|
-
|
|
299
256
|
if (cellBefore && cellBefore.borderColor) {
|
|
300
257
|
if (cellBefore.border ? cellBefore.border[2] : this.layout.defaultBorder) {
|
|
301
258
|
borderColor = cellBefore.borderColor[2];
|
|
302
259
|
}
|
|
303
260
|
}
|
|
304
|
-
}
|
|
305
|
-
|
|
261
|
+
}
|
|
306
262
|
|
|
263
|
+
// the current cell
|
|
307
264
|
if (borderColor == null && vLineColIndex < body.length) {
|
|
308
265
|
currentCell = body[vLineRowIndex][vLineColIndex];
|
|
309
|
-
|
|
310
266
|
if (currentCell && currentCell.borderColor) {
|
|
311
267
|
if (currentCell.border ? currentCell.border[0] : this.layout.defaultBorder) {
|
|
312
268
|
borderColor = currentCell.borderColor[0];
|
|
313
269
|
}
|
|
314
270
|
}
|
|
315
271
|
}
|
|
316
|
-
|
|
317
272
|
if (borderColor == null && cellBefore && cellBefore._rowSpanCurrentOffset) {
|
|
318
273
|
let rowCellBeforeAbove = body[vLineRowIndex - cellBefore._rowSpanCurrentOffset][beforeVLineColIndex];
|
|
319
|
-
|
|
320
274
|
if (rowCellBeforeAbove.borderColor) {
|
|
321
275
|
if (rowCellBeforeAbove.border ? rowCellBeforeAbove.border[2] : this.layout.defaultBorder) {
|
|
322
276
|
borderColor = rowCellBeforeAbove.borderColor[2];
|
|
323
277
|
}
|
|
324
278
|
}
|
|
325
279
|
}
|
|
326
|
-
|
|
327
280
|
if (borderColor == null && currentCell && currentCell._rowSpanCurrentOffset) {
|
|
328
281
|
let rowCurrentCellAbove = body[vLineRowIndex - currentCell._rowSpanCurrentOffset][vLineColIndex];
|
|
329
|
-
|
|
330
282
|
if (rowCurrentCellAbove.borderColor) {
|
|
331
283
|
if (rowCurrentCellAbove.border ? rowCurrentCellAbove.border[2] : this.layout.defaultBorder) {
|
|
332
284
|
borderColor = rowCurrentCellAbove.borderColor[2];
|
|
333
285
|
}
|
|
334
286
|
}
|
|
335
287
|
}
|
|
336
|
-
|
|
337
288
|
if (borderColor == null) {
|
|
338
289
|
borderColor = typeof this.layout.vLineColor === 'function' ? this.layout.vLineColor(vLineColIndex, this.tableNode, vLineRowIndex) : this.layout.vLineColor;
|
|
339
290
|
}
|
|
340
|
-
|
|
341
291
|
writer.addVector({
|
|
342
292
|
type: 'line',
|
|
343
293
|
x1: x + width / 2,
|
|
@@ -352,18 +302,15 @@ class TableProcessor {
|
|
|
352
302
|
currentCell = null;
|
|
353
303
|
borderColor = null;
|
|
354
304
|
}
|
|
355
|
-
|
|
356
305
|
endTable(writer) {
|
|
357
306
|
if (this.cleanUpRepeatables) {
|
|
358
307
|
writer.popFromRepeatables();
|
|
359
308
|
}
|
|
360
309
|
}
|
|
361
|
-
|
|
362
310
|
endRow(rowIndex, writer, pageBreaks) {
|
|
363
311
|
const getLineXs = () => {
|
|
364
312
|
let result = [];
|
|
365
313
|
let cols = 0;
|
|
366
|
-
|
|
367
314
|
for (let i = 0, l = this.tableNode.table.body[rowIndex].length; i < l; i++) {
|
|
368
315
|
if (!cols) {
|
|
369
316
|
result.push({
|
|
@@ -373,19 +320,16 @@ class TableProcessor {
|
|
|
373
320
|
let item = this.tableNode.table.body[rowIndex][i];
|
|
374
321
|
cols = item._colSpan || item.colSpan || 0;
|
|
375
322
|
}
|
|
376
|
-
|
|
377
323
|
if (cols > 0) {
|
|
378
324
|
cols--;
|
|
379
325
|
}
|
|
380
326
|
}
|
|
381
|
-
|
|
382
327
|
result.push({
|
|
383
328
|
x: this.rowSpanData[this.rowSpanData.length - 1].left,
|
|
384
329
|
index: this.rowSpanData.length - 1
|
|
385
330
|
});
|
|
386
331
|
return result;
|
|
387
332
|
};
|
|
388
|
-
|
|
389
333
|
writer.removeListener('pageChanged', this.rowCallback);
|
|
390
334
|
writer.context().moveDown(this.layout.paddingBottom(rowIndex, this.tableNode));
|
|
391
335
|
writer.context().availableHeight += this.reservedAtBottom;
|
|
@@ -399,7 +343,6 @@ class TableProcessor {
|
|
|
399
343
|
y0: this.rowTopY,
|
|
400
344
|
page: hasBreaks ? pageBreaks[0].prevPage : endingPage
|
|
401
345
|
});
|
|
402
|
-
|
|
403
346
|
if (hasBreaks) {
|
|
404
347
|
for (let i = 0, l = pageBreaks.length; i < l; i++) {
|
|
405
348
|
let pageBreak = pageBreaks[i];
|
|
@@ -410,74 +353,64 @@ class TableProcessor {
|
|
|
410
353
|
});
|
|
411
354
|
}
|
|
412
355
|
}
|
|
413
|
-
|
|
414
356
|
ys[ys.length - 1].y1 = endingY;
|
|
415
357
|
let skipOrphanePadding = ys[0].y1 - ys[0].y0 === this.rowPaddingTop;
|
|
416
|
-
|
|
417
358
|
for (let yi = skipOrphanePadding ? 1 : 0, yl = ys.length; yi < yl; yi++) {
|
|
418
359
|
let willBreak = yi < ys.length - 1;
|
|
419
360
|
let rowBreakWithoutHeader = yi > 0 && !this.headerRows;
|
|
420
361
|
let hzLineOffset = rowBreakWithoutHeader ? 0 : this.topLineWidth;
|
|
421
362
|
let y1 = ys[yi].y0;
|
|
422
363
|
let y2 = ys[yi].y1;
|
|
423
|
-
|
|
424
364
|
if (willBreak) {
|
|
425
365
|
y2 = y2 + this.rowPaddingBottom;
|
|
426
366
|
}
|
|
427
|
-
|
|
428
367
|
if (writer.context().page != ys[yi].page) {
|
|
429
|
-
writer.context().page = ys[yi].page;
|
|
430
|
-
// TableProcessor should be pageChanged listener, instead of processRow
|
|
368
|
+
writer.context().page = ys[yi].page;
|
|
431
369
|
|
|
370
|
+
//TODO: buggy, availableHeight should be updated on every pageChanged event
|
|
371
|
+
// TableProcessor should be pageChanged listener, instead of processRow
|
|
432
372
|
this.reservedAtBottom = 0;
|
|
433
373
|
}
|
|
434
|
-
|
|
435
374
|
for (let i = 0, l = xs.length; i < l; i++) {
|
|
436
375
|
let leftCellBorder = false;
|
|
437
376
|
let rightCellBorder = false;
|
|
438
|
-
let colIndex = xs[i].index;
|
|
377
|
+
let colIndex = xs[i].index;
|
|
439
378
|
|
|
379
|
+
// current cell
|
|
440
380
|
if (colIndex < body[rowIndex].length) {
|
|
441
381
|
let cell = body[rowIndex][colIndex];
|
|
442
382
|
leftCellBorder = cell.border ? cell.border[0] : this.layout.defaultBorder;
|
|
443
383
|
rightCellBorder = cell.border ? cell.border[2] : this.layout.defaultBorder;
|
|
444
|
-
}
|
|
445
|
-
|
|
384
|
+
}
|
|
446
385
|
|
|
386
|
+
// before cell
|
|
447
387
|
if (colIndex > 0 && !leftCellBorder) {
|
|
448
388
|
let cell = body[rowIndex][colIndex - 1];
|
|
449
389
|
leftCellBorder = cell.border ? cell.border[2] : this.layout.defaultBorder;
|
|
450
|
-
}
|
|
451
|
-
|
|
390
|
+
}
|
|
452
391
|
|
|
392
|
+
// after cell
|
|
453
393
|
if (colIndex + 1 < body[rowIndex].length && !rightCellBorder) {
|
|
454
394
|
let cell = body[rowIndex][colIndex + 1];
|
|
455
395
|
rightCellBorder = cell.border ? cell.border[0] : this.layout.defaultBorder;
|
|
456
396
|
}
|
|
457
|
-
|
|
458
397
|
if (leftCellBorder) {
|
|
459
398
|
this.drawVerticalLine(xs[i].x, y1 - hzLineOffset, y2 + this.bottomLineWidth, xs[i].index, writer, rowIndex, xs[i - 1] ? xs[i - 1].index : null);
|
|
460
399
|
}
|
|
461
|
-
|
|
462
400
|
if (i < l - 1) {
|
|
463
401
|
let fillColor = body[rowIndex][colIndex].fillColor;
|
|
464
402
|
let fillOpacity = body[rowIndex][colIndex].fillOpacity;
|
|
465
|
-
|
|
466
403
|
if (!fillColor) {
|
|
467
404
|
fillColor = typeof this.layout.fillColor === 'function' ? this.layout.fillColor(rowIndex, this.tableNode, colIndex) : this.layout.fillColor;
|
|
468
405
|
}
|
|
469
|
-
|
|
470
406
|
if (!(0, _variableType.isNumber)(fillOpacity)) {
|
|
471
407
|
fillOpacity = typeof this.layout.fillOpacity === 'function' ? this.layout.fillOpacity(rowIndex, this.tableNode, colIndex) : this.layout.fillOpacity;
|
|
472
408
|
}
|
|
473
|
-
|
|
474
409
|
var overlayPattern = body[rowIndex][colIndex].overlayPattern;
|
|
475
410
|
var overlayOpacity = body[rowIndex][colIndex].overlayOpacity;
|
|
476
|
-
|
|
477
411
|
if (fillColor || overlayPattern) {
|
|
478
412
|
let widthLeftBorder = leftCellBorder ? this.layout.vLineWidth(colIndex, this.tableNode) : 0;
|
|
479
413
|
let widthRightBorder;
|
|
480
|
-
|
|
481
414
|
if ((colIndex === 0 || colIndex + 1 == body[rowIndex].length) && !rightCellBorder) {
|
|
482
415
|
widthRightBorder = this.layout.vLineWidth(colIndex + 1, this.tableNode);
|
|
483
416
|
} else if (rightCellBorder) {
|
|
@@ -485,14 +418,12 @@ class TableProcessor {
|
|
|
485
418
|
} else {
|
|
486
419
|
widthRightBorder = 0;
|
|
487
420
|
}
|
|
488
|
-
|
|
489
421
|
let x1f = this.dontBreakRows ? xs[i].x + widthLeftBorder : xs[i].x + widthLeftBorder / 2;
|
|
490
422
|
let y1f = this.dontBreakRows ? y1 : y1 - hzLineOffset / 2;
|
|
491
423
|
let x2f = xs[i + 1].x + widthRightBorder;
|
|
492
424
|
let y2f = this.dontBreakRows ? y2 + this.bottomLineWidth : y2 + this.bottomLineWidth / 2;
|
|
493
425
|
var bgWidth = x2f - x1f;
|
|
494
426
|
var bgHeight = y2f - y1f;
|
|
495
|
-
|
|
496
427
|
if (fillColor) {
|
|
497
428
|
writer.addVector({
|
|
498
429
|
type: 'rect',
|
|
@@ -505,7 +436,6 @@ class TableProcessor {
|
|
|
505
436
|
fillOpacity: fillOpacity
|
|
506
437
|
}, false, true, writer.context().backgroundLength[writer.context().page]);
|
|
507
438
|
}
|
|
508
|
-
|
|
509
439
|
if (overlayPattern) {
|
|
510
440
|
writer.addVector({
|
|
511
441
|
type: 'rect',
|
|
@@ -521,61 +451,52 @@ class TableProcessor {
|
|
|
521
451
|
}
|
|
522
452
|
}
|
|
523
453
|
}
|
|
524
|
-
|
|
525
454
|
if (willBreak && this.layout.hLineWhenBroken !== false) {
|
|
526
455
|
this.drawHorizontalLine(rowIndex + 1, writer, y2);
|
|
527
456
|
}
|
|
528
|
-
|
|
529
457
|
if (rowBreakWithoutHeader && this.layout.hLineWhenBroken !== false) {
|
|
530
458
|
this.drawHorizontalLine(rowIndex, writer, y1);
|
|
531
459
|
}
|
|
532
460
|
}
|
|
533
|
-
|
|
534
461
|
writer.context().page = endingPage;
|
|
535
462
|
writer.context().y = endingY;
|
|
536
463
|
let row = this.tableNode.table.body[rowIndex];
|
|
537
|
-
|
|
538
464
|
for (let i = 0, l = row.length; i < l; i++) {
|
|
539
465
|
if (row[i].rowSpan) {
|
|
540
|
-
this.rowSpanData[i].rowSpan = row[i].rowSpan;
|
|
466
|
+
this.rowSpanData[i].rowSpan = row[i].rowSpan;
|
|
541
467
|
|
|
468
|
+
// fix colSpans
|
|
542
469
|
if (row[i].colSpan && row[i].colSpan > 1) {
|
|
543
470
|
for (let j = 1; j < row[i].rowSpan; j++) {
|
|
544
471
|
this.tableNode.table.body[rowIndex + j][i]._colSpan = row[i].colSpan;
|
|
545
472
|
}
|
|
546
|
-
}
|
|
547
|
-
|
|
473
|
+
}
|
|
548
474
|
|
|
475
|
+
// fix rowSpans
|
|
549
476
|
if (row[i].rowSpan && row[i].rowSpan > 1) {
|
|
550
477
|
for (let j = 1; j < row[i].rowSpan; j++) {
|
|
551
478
|
this.tableNode.table.body[rowIndex + j][i]._rowSpanCurrentOffset = j;
|
|
552
479
|
}
|
|
553
480
|
}
|
|
554
481
|
}
|
|
555
|
-
|
|
556
482
|
if (this.rowSpanData[i].rowSpan > 0) {
|
|
557
483
|
this.rowSpanData[i].rowSpan--;
|
|
558
484
|
}
|
|
559
485
|
}
|
|
560
|
-
|
|
561
486
|
this.drawHorizontalLine(rowIndex + 1, writer);
|
|
562
|
-
|
|
563
487
|
if (this.headerRows && rowIndex === this.headerRows - 1) {
|
|
564
488
|
this.headerRepeatable = writer.currentBlockToRepeatable();
|
|
565
489
|
}
|
|
566
|
-
|
|
567
490
|
if (this.dontBreakRows) {
|
|
568
491
|
const pageChangedCallback = () => {
|
|
569
492
|
if (!this.headerRows && this.layout.hLineWhenBroken !== false) {
|
|
570
493
|
this.drawHorizontalLine(rowIndex, writer);
|
|
571
494
|
}
|
|
572
495
|
};
|
|
573
|
-
|
|
574
496
|
writer.addListener('pageChanged', pageChangedCallback);
|
|
575
497
|
writer.commitUnbreakableBlock();
|
|
576
498
|
writer.removeListener('pageChanged', pageChangedCallback);
|
|
577
499
|
}
|
|
578
|
-
|
|
579
500
|
if (this.headerRepeatable && (rowIndex === this.rowsWithoutPageBreak - 1 || rowIndex === this.tableNode.table.body.length - 1)) {
|
|
580
501
|
writer.commitUnbreakableBlock();
|
|
581
502
|
writer.pushToRepeatables(this.headerRepeatable);
|
|
@@ -583,8 +504,6 @@ class TableProcessor {
|
|
|
583
504
|
this.headerRepeatable = null;
|
|
584
505
|
}
|
|
585
506
|
}
|
|
586
|
-
|
|
587
507
|
}
|
|
588
|
-
|
|
589
508
|
var _default = TableProcessor;
|
|
590
509
|
exports.default = _default;
|