pdfmake 0.3.0-beta.6 → 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.
Files changed (55) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +1 -1
  3. package/build/pdfmake.js +36523 -36424
  4. package/build/pdfmake.js.map +1 -1
  5. package/build/pdfmake.min.js +2 -2
  6. package/build/pdfmake.min.js.map +1 -1
  7. package/package.json +21 -20
  8. package/src/DocMeasure.js +3 -0
  9. package/src/Printer.js +1 -0
  10. package/src/TableProcessor.js +4 -0
  11. package/src/TextDecorator.js +1 -1
  12. package/src/qrEnc.js +5 -3
  13. package/js/3rd-party/svg-to-pdfkit/source.js +0 -3628
  14. package/js/3rd-party/svg-to-pdfkit.js +0 -7
  15. package/js/DocMeasure.js +0 -624
  16. package/js/DocPreprocessor.js +0 -238
  17. package/js/DocumentContext.js +0 -265
  18. package/js/ElementWriter.js +0 -331
  19. package/js/LayoutBuilder.js +0 -694
  20. package/js/Line.js +0 -105
  21. package/js/OutputDocument.js +0 -76
  22. package/js/OutputDocumentServer.js +0 -27
  23. package/js/PDFDocument.js +0 -144
  24. package/js/PageElementWriter.js +0 -140
  25. package/js/PageSize.js +0 -74
  26. package/js/Printer.js +0 -290
  27. package/js/Renderer.js +0 -375
  28. package/js/SVGMeasure.js +0 -69
  29. package/js/StyleContextStack.js +0 -181
  30. package/js/TableProcessor.js +0 -508
  31. package/js/TextBreaker.js +0 -139
  32. package/js/TextDecorator.js +0 -143
  33. package/js/TextInlines.js +0 -206
  34. package/js/URLResolver.js +0 -73
  35. package/js/base.js +0 -52
  36. package/js/browser-extensions/OutputDocumentBrowser.js +0 -118
  37. package/js/browser-extensions/URLBrowserResolver.js +0 -76
  38. package/js/browser-extensions/fonts/Roboto.js +0 -38
  39. package/js/browser-extensions/index.js +0 -53
  40. package/js/browser-extensions/pdfMake.js +0 -15
  41. package/js/browser-extensions/standard-fonts/Courier.js +0 -38
  42. package/js/browser-extensions/standard-fonts/Helvetica.js +0 -38
  43. package/js/browser-extensions/standard-fonts/Symbol.js +0 -23
  44. package/js/browser-extensions/standard-fonts/Times.js +0 -38
  45. package/js/browser-extensions/standard-fonts/ZapfDingbats.js +0 -23
  46. package/js/browser-extensions/virtual-fs-cjs.js +0 -3
  47. package/js/columnCalculator.js +0 -129
  48. package/js/helpers/node.js +0 -98
  49. package/js/helpers/tools.js +0 -40
  50. package/js/helpers/variableType.js +0 -47
  51. package/js/index.js +0 -15
  52. package/js/qrEnc.js +0 -720
  53. package/js/standardPageSizes.js +0 -56
  54. package/js/tableLayouts.js +0 -98
  55. package/js/virtual-fs.js +0 -60
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = void 0;
5
- var _source = _interopRequireDefault(require("./svg-to-pdfkit/source.js"));
6
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7
- var _default = exports.default = _source.default;
package/js/DocMeasure.js DELETED
@@ -1,624 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = void 0;
5
- var _TextInlines = _interopRequireDefault(require("./TextInlines"));
6
- var _StyleContextStack = _interopRequireDefault(require("./StyleContextStack"));
7
- var _columnCalculator = _interopRequireDefault(require("./columnCalculator"));
8
- var _tableLayouts = require("./tableLayouts");
9
- var _variableType = require("./helpers/variableType");
10
- var _node = require("./helpers/node");
11
- var _tools = require("./helpers/tools");
12
- var _qrEnc = _interopRequireDefault(require("./qrEnc.js"));
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
- class DocMeasure {
15
- constructor(pdfDocument, styleDictionary, defaultStyle, svgMeasure, tableLayouts) {
16
- this.pdfDocument = pdfDocument;
17
- this.textInlines = new _TextInlines.default(pdfDocument);
18
- this.styleStack = new _StyleContextStack.default(styleDictionary, defaultStyle);
19
- this.svgMeasure = svgMeasure;
20
- this.tableLayouts = tableLayouts;
21
- this.autoImageIndex = 1;
22
- }
23
-
24
- /**
25
- * Measures all nodes and sets min/max-width properties required for the second
26
- * layout-pass.
27
- *
28
- * @param {object} docStructure document-definition-object
29
- * @returns {object} document-measurement-object
30
- */
31
- measureDocument(docStructure) {
32
- return this.measureNode(docStructure);
33
- }
34
- measureNode(node) {
35
- return this.styleStack.auto(node, () => {
36
- // TODO: refactor + rethink whether this is the proper way to handle margins
37
- node._margin = (0, _node.getNodeMargin)(node, this.styleStack);
38
- if (node.columns) {
39
- return extendMargins(this.measureColumns(node));
40
- } else if (node.stack) {
41
- return extendMargins(this.measureVerticalContainer(node));
42
- } else if (node.ul) {
43
- return extendMargins(this.measureUnorderedList(node));
44
- } else if (node.ol) {
45
- return extendMargins(this.measureOrderedList(node));
46
- } else if (node.table) {
47
- return extendMargins(this.measureTable(node));
48
- } else if (node.text !== undefined) {
49
- return extendMargins(this.measureLeaf(node));
50
- } else if (node.toc) {
51
- return extendMargins(this.measureToc(node));
52
- } else if (node.image) {
53
- return extendMargins(this.measureImage(node));
54
- } else if (node.svg) {
55
- return extendMargins(this.measureSVG(node));
56
- } else if (node.canvas) {
57
- return extendMargins(this.measureCanvas(node));
58
- } else if (node.qr) {
59
- return extendMargins(this.measureQr(node));
60
- } else if (node.attachment) {
61
- return extendMargins(this.measureAttachment(node));
62
- } else {
63
- throw new Error(`Unrecognized document structure: ${(0, _node.stringifyNode)(node)}`);
64
- }
65
- });
66
- function extendMargins(node) {
67
- let margin = node._margin;
68
- if (margin) {
69
- node._minWidth += margin[0] + margin[2];
70
- node._maxWidth += margin[0] + margin[2];
71
- }
72
- return node;
73
- }
74
- }
75
- measureImageWithDimensions(node, dimensions) {
76
- if (node.fit) {
77
- let factor = dimensions.width / dimensions.height > node.fit[0] / node.fit[1] ? node.fit[0] / dimensions.width : node.fit[1] / dimensions.height;
78
- node._width = node._minWidth = node._maxWidth = dimensions.width * factor;
79
- node._height = dimensions.height * factor;
80
- } else {
81
- node._width = node._minWidth = node._maxWidth = node.width || dimensions.width;
82
- node._height = node.height || dimensions.height * node._width / dimensions.width;
83
- if ((0, _variableType.isNumber)(node.maxWidth) && node.maxWidth < node._width) {
84
- node._width = node._minWidth = node._maxWidth = node.maxWidth;
85
- node._height = node._width * dimensions.height / dimensions.width;
86
- }
87
- if ((0, _variableType.isNumber)(node.maxHeight) && node.maxHeight < node._height) {
88
- node._height = node.maxHeight;
89
- node._width = node._minWidth = node._maxWidth = node._height * dimensions.width / dimensions.height;
90
- }
91
- if ((0, _variableType.isNumber)(node.minWidth) && node.minWidth > node._width) {
92
- node._width = node._minWidth = node._maxWidth = node.minWidth;
93
- node._height = node._width * dimensions.height / dimensions.width;
94
- }
95
- if ((0, _variableType.isNumber)(node.minHeight) && node.minHeight > node._height) {
96
- node._height = node.minHeight;
97
- node._width = node._minWidth = node._maxWidth = node._height * dimensions.width / dimensions.height;
98
- }
99
- }
100
- node._alignment = this.styleStack.getProperty('alignment');
101
- }
102
- convertIfBase64Image(node) {
103
- if (/^data:image\/(jpeg|jpg|png);base64,/.test(node.image)) {
104
- // base64 image
105
- let label = `$$pdfmake$$${this.autoImageIndex++}`;
106
- this.pdfDocument.images[label] = node.image;
107
- node.image = label;
108
- }
109
- }
110
- measureImage(node) {
111
- this.convertIfBase64Image(node);
112
- let image = this.pdfDocument.provideImage(node.image);
113
- let imageSize = {
114
- width: image.width,
115
- height: image.height
116
- };
117
- this.measureImageWithDimensions(node, imageSize);
118
- return node;
119
- }
120
- measureSVG(node) {
121
- let dimensions = this.svgMeasure.measureSVG(node.svg);
122
- this.measureImageWithDimensions(node, dimensions);
123
- node.font = this.styleStack.getProperty('font');
124
-
125
- // scale SVG based on final dimension
126
- node.svg = this.svgMeasure.writeDimensions(node.svg, {
127
- width: node._width,
128
- height: node._height
129
- });
130
- return node;
131
- }
132
- measureLeaf(node) {
133
- if (node._textRef && node._textRef._textNodeRef.text) {
134
- node.text = node._textRef._textNodeRef.text;
135
- }
136
-
137
- // Make sure style properties of the node itself are considered when building inlines.
138
- // We could also just pass [node] to buildInlines, but that fails for bullet points.
139
- let styleStack = this.styleStack.clone();
140
- styleStack.push(node);
141
- let data = this.textInlines.buildInlines(node.text, styleStack);
142
- node._inlines = data.items;
143
- node._minWidth = data.minWidth;
144
- node._maxWidth = data.maxWidth;
145
- return node;
146
- }
147
- measureToc(node) {
148
- if (node.toc.title) {
149
- node.toc.title = this.measureNode(node.toc.title);
150
- }
151
- if (node.toc._items.length > 0) {
152
- let body = [];
153
- let textStyle = node.toc.textStyle || {};
154
- let numberStyle = node.toc.numberStyle || textStyle;
155
- let textMargin = node.toc.textMargin || [0, 0, 0, 0];
156
- for (let i = 0, l = node.toc._items.length; i < l; i++) {
157
- let item = node.toc._items[i];
158
- let lineStyle = item._textNodeRef.tocStyle || textStyle;
159
- let lineMargin = item._textNodeRef.tocMargin || textMargin;
160
- let lineNumberStyle = item._textNodeRef.tocNumberStyle || numberStyle;
161
- let destination = (0, _node.getNodeId)(item._nodeRef);
162
- body.push([{
163
- text: item._textNodeRef.text,
164
- linkToDestination: destination,
165
- alignment: 'left',
166
- style: lineStyle,
167
- margin: lineMargin
168
- }, {
169
- text: '00000',
170
- linkToDestination: destination,
171
- alignment: 'right',
172
- _tocItemRef: item._nodeRef,
173
- style: lineNumberStyle,
174
- margin: [0, lineMargin[1], 0, lineMargin[3]]
175
- }]);
176
- }
177
- node.toc._table = {
178
- table: {
179
- dontBreakRows: true,
180
- widths: ['*', 'auto'],
181
- body: body
182
- },
183
- layout: 'noBorders'
184
- };
185
- node.toc._table = this.measureNode(node.toc._table);
186
- }
187
- return node;
188
- }
189
- measureVerticalContainer(node) {
190
- let items = node.stack;
191
- node._minWidth = 0;
192
- node._maxWidth = 0;
193
- for (let i = 0, l = items.length; i < l; i++) {
194
- items[i] = this.measureNode(items[i]);
195
- node._minWidth = Math.max(node._minWidth, items[i]._minWidth);
196
- node._maxWidth = Math.max(node._maxWidth, items[i]._maxWidth);
197
- }
198
- return node;
199
- }
200
- gapSizeForList() {
201
- return this.textInlines.sizeOfText('9. ', this.styleStack);
202
- }
203
- buildUnorderedMarker(styleStack, gapSize, type) {
204
- function buildDisc(gapSize, color) {
205
- // TODO: ascender-based calculations
206
- let radius = gapSize.fontSize / 6;
207
- return {
208
- canvas: [{
209
- x: radius,
210
- y: gapSize.height / gapSize.lineHeight + gapSize.descender - gapSize.fontSize / 3,
211
- r1: radius,
212
- r2: radius,
213
- type: 'ellipse',
214
- color: color
215
- }]
216
- };
217
- }
218
- function buildSquare(gapSize, color) {
219
- // TODO: ascender-based calculations
220
- let size = gapSize.fontSize / 3;
221
- return {
222
- canvas: [{
223
- x: 0,
224
- y: gapSize.height / gapSize.lineHeight + gapSize.descender - gapSize.fontSize / 3 - size / 2,
225
- h: size,
226
- w: size,
227
- type: 'rect',
228
- color: color
229
- }]
230
- };
231
- }
232
- function buildCircle(gapSize, color) {
233
- // TODO: ascender-based calculations
234
- let radius = gapSize.fontSize / 6;
235
- return {
236
- canvas: [{
237
- x: radius,
238
- y: gapSize.height / gapSize.lineHeight + gapSize.descender - gapSize.fontSize / 3,
239
- r1: radius,
240
- r2: radius,
241
- type: 'ellipse',
242
- lineColor: color
243
- }]
244
- };
245
- }
246
- let marker;
247
- let color = styleStack.getProperty('markerColor') || styleStack.getProperty('color') || 'black';
248
- switch (type) {
249
- case 'circle':
250
- marker = buildCircle(gapSize, color);
251
- break;
252
- case 'square':
253
- marker = buildSquare(gapSize, color);
254
- break;
255
- case 'none':
256
- marker = {};
257
- break;
258
- case 'disc':
259
- default:
260
- marker = buildDisc(gapSize, color);
261
- break;
262
- }
263
- marker._minWidth = marker._maxWidth = gapSize.width;
264
- marker._minHeight = marker._maxHeight = gapSize.height;
265
- return marker;
266
- }
267
- buildOrderedMarker(counter, styleStack, type, separator) {
268
- function prepareAlpha(counter) {
269
- function toAlpha(num) {
270
- return (num >= 26 ? toAlpha((num / 26 >> 0) - 1) : '') + 'abcdefghijklmnopqrstuvwxyz'[num % 26 >> 0];
271
- }
272
- if (counter < 1) {
273
- return counter.toString();
274
- }
275
- return toAlpha(counter - 1);
276
- }
277
- function prepareRoman(counter) {
278
- if (counter < 1 || counter > 4999) {
279
- return counter.toString();
280
- }
281
- let num = counter;
282
- let lookup = {
283
- M: 1000,
284
- CM: 900,
285
- D: 500,
286
- CD: 400,
287
- C: 100,
288
- XC: 90,
289
- L: 50,
290
- XL: 40,
291
- X: 10,
292
- IX: 9,
293
- V: 5,
294
- IV: 4,
295
- I: 1
296
- };
297
- let roman = '';
298
- for (let i in lookup) {
299
- while (num >= lookup[i]) {
300
- roman += i;
301
- num -= lookup[i];
302
- }
303
- }
304
- return roman;
305
- }
306
- function prepareDecimal(counter) {
307
- return counter.toString();
308
- }
309
- let counterText;
310
- switch (type) {
311
- case 'none':
312
- counterText = null;
313
- break;
314
- case 'upper-alpha':
315
- counterText = prepareAlpha(counter).toUpperCase();
316
- break;
317
- case 'lower-alpha':
318
- counterText = prepareAlpha(counter);
319
- break;
320
- case 'upper-roman':
321
- counterText = prepareRoman(counter);
322
- break;
323
- case 'lower-roman':
324
- counterText = prepareRoman(counter).toLowerCase();
325
- break;
326
- case 'decimal':
327
- default:
328
- counterText = prepareDecimal(counter);
329
- break;
330
- }
331
- if (counterText === null) {
332
- return {};
333
- }
334
- if (separator) {
335
- if (Array.isArray(separator)) {
336
- if (separator[0]) {
337
- counterText = separator[0] + counterText;
338
- }
339
- if (separator[1]) {
340
- counterText += separator[1];
341
- }
342
- counterText += ' ';
343
- } else {
344
- counterText += `${separator} `;
345
- }
346
- }
347
- let textArray = {
348
- text: counterText
349
- };
350
- let markerColor = styleStack.getProperty('markerColor');
351
- if (markerColor) {
352
- textArray.color = markerColor;
353
- }
354
- return {
355
- _inlines: this.textInlines.buildInlines(textArray, styleStack).items
356
- };
357
- }
358
- measureUnorderedList(node) {
359
- let style = this.styleStack.clone();
360
- let items = node.ul;
361
- node.type = node.type || 'disc';
362
- node._gapSize = this.gapSizeForList();
363
- node._minWidth = 0;
364
- node._maxWidth = 0;
365
- for (let i = 0, l = items.length; i < l; i++) {
366
- let item = items[i] = this.measureNode(items[i]);
367
- if (!item.ol && !item.ul) {
368
- item.listMarker = this.buildUnorderedMarker(style, node._gapSize, item.listType || node.type);
369
- }
370
- node._minWidth = Math.max(node._minWidth, items[i]._minWidth + node._gapSize.width);
371
- node._maxWidth = Math.max(node._maxWidth, items[i]._maxWidth + node._gapSize.width);
372
- }
373
- return node;
374
- }
375
- measureOrderedList(node) {
376
- let style = this.styleStack.clone();
377
- let items = node.ol;
378
- node.type = node.type || 'decimal';
379
- node.separator = node.separator || '.';
380
- node.reversed = node.reversed || false;
381
- if (!(0, _variableType.isNumber)(node.start)) {
382
- node.start = node.reversed ? items.length : 1;
383
- }
384
- node._gapSize = this.gapSizeForList();
385
- node._minWidth = 0;
386
- node._maxWidth = 0;
387
- let counter = node.start;
388
- for (let i = 0, l = items.length; i < l; i++) {
389
- let item = items[i] = this.measureNode(items[i]);
390
- if (!item.ol && !item.ul) {
391
- let counterValue = (0, _variableType.isNumber)(item.counter) ? item.counter : counter;
392
- item.listMarker = this.buildOrderedMarker(counterValue, style, item.listType || node.type, node.separator);
393
- if (item.listMarker._inlines) {
394
- node._gapSize.width = Math.max(node._gapSize.width, item.listMarker._inlines[0].width);
395
- }
396
- } // TODO: else - nested lists numbering
397
-
398
- node._minWidth = Math.max(node._minWidth, items[i]._minWidth);
399
- node._maxWidth = Math.max(node._maxWidth, items[i]._maxWidth);
400
- if (node.reversed) {
401
- counter--;
402
- } else {
403
- counter++;
404
- }
405
- }
406
- node._minWidth += node._gapSize.width;
407
- node._maxWidth += node._gapSize.width;
408
- for (let i = 0, l = items.length; i < l; i++) {
409
- let item = items[i];
410
- if (!item.ol && !item.ul) {
411
- item.listMarker._minWidth = item.listMarker._maxWidth = node._gapSize.width;
412
- }
413
- }
414
- return node;
415
- }
416
- measureColumns(node) {
417
- let columns = node.columns;
418
- node._gap = this.styleStack.getProperty('columnGap') || 0;
419
- for (let i = 0, l = columns.length; i < l; i++) {
420
- columns[i] = this.measureNode(columns[i]);
421
- }
422
- let measures = _columnCalculator.default.measureMinMax(columns);
423
- let numGaps = columns.length > 0 ? columns.length - 1 : 0;
424
- node._minWidth = measures.min + node._gap * numGaps;
425
- node._maxWidth = measures.max + node._gap * numGaps;
426
- return node;
427
- }
428
- measureTable(node) {
429
- extendTableWidths(node);
430
- node._layout = getLayout(this.tableLayouts);
431
- node._offsets = getOffsets(node._layout);
432
- let colSpans = [];
433
- let col;
434
- let row;
435
- let cols;
436
- let rows;
437
- for (col = 0, cols = node.table.body[0].length; col < cols; col++) {
438
- let c = node.table.widths[col];
439
- c._minWidth = 0;
440
- c._maxWidth = 0;
441
- for (row = 0, rows = node.table.body.length; row < rows; row++) {
442
- let rowData = node.table.body[row];
443
- let data = rowData[col];
444
- if (data === undefined) {
445
- throw new Error(`Malformed table row, a cell is undefined.\nRow index: ${row}\nColumn index: ${col}\nRow data: ${(0, _node.stringifyNode)(rowData)}`);
446
- }
447
- if (data === null) {
448
- // transform to object
449
- data = '';
450
- }
451
- if (!data._span) {
452
- data = rowData[col] = this.styleStack.auto(data, measureCb(this, data));
453
- if (data.colSpan && data.colSpan > 1) {
454
- markSpans(rowData, col, data.colSpan);
455
- colSpans.push({
456
- col: col,
457
- span: data.colSpan,
458
- minWidth: data._minWidth,
459
- maxWidth: data._maxWidth
460
- });
461
- } else {
462
- c._minWidth = Math.max(c._minWidth, data._minWidth);
463
- c._maxWidth = Math.max(c._maxWidth, data._maxWidth);
464
- }
465
- }
466
- if (data.rowSpan && data.rowSpan > 1) {
467
- markVSpans(node.table, row, col, data.rowSpan);
468
- }
469
- }
470
- }
471
- extendWidthsForColSpans();
472
- let measures = _columnCalculator.default.measureMinMax(node.table.widths);
473
- node._minWidth = measures.min + node._offsets.total;
474
- node._maxWidth = measures.max + node._offsets.total;
475
- return node;
476
- function measureCb(_this, data) {
477
- return () => {
478
- if ((0, _variableType.isObject)(data)) {
479
- data.fillColor = _this.styleStack.getProperty('fillColor');
480
- data.fillOpacity = _this.styleStack.getProperty('fillOpacity');
481
- }
482
- return _this.measureNode(data);
483
- };
484
- }
485
- function getLayout(tableLayouts) {
486
- let layout = node.layout;
487
- if ((0, _variableType.isString)(layout)) {
488
- layout = tableLayouts[layout];
489
- }
490
- return (0, _tools.pack)(_tableLayouts.defaultTableLayout, layout);
491
- }
492
- function getOffsets(layout) {
493
- let offsets = [];
494
- let totalOffset = 0;
495
- let prevRightPadding = 0;
496
- for (let i = 0, l = node.table.widths.length; i < l; i++) {
497
- let lOffset = prevRightPadding + layout.vLineWidth(i, node) + layout.paddingLeft(i, node);
498
- offsets.push(lOffset);
499
- totalOffset += lOffset;
500
- prevRightPadding = layout.paddingRight(i, node);
501
- }
502
- totalOffset += prevRightPadding + layout.vLineWidth(node.table.widths.length, node);
503
- return {
504
- total: totalOffset,
505
- offsets: offsets
506
- };
507
- }
508
- function extendWidthsForColSpans() {
509
- let q;
510
- let j;
511
- for (let i = 0, l = colSpans.length; i < l; i++) {
512
- let span = colSpans[i];
513
- let currentMinMax = getMinMax(span.col, span.span, node._offsets);
514
- let minDifference = span.minWidth - currentMinMax.minWidth;
515
- let maxDifference = span.maxWidth - currentMinMax.maxWidth;
516
- if (minDifference > 0) {
517
- q = minDifference / span.span;
518
- for (j = 0; j < span.span; j++) {
519
- node.table.widths[span.col + j]._minWidth += q;
520
- }
521
- }
522
- if (maxDifference > 0) {
523
- q = maxDifference / span.span;
524
- for (j = 0; j < span.span; j++) {
525
- node.table.widths[span.col + j]._maxWidth += q;
526
- }
527
- }
528
- }
529
- }
530
- function getMinMax(col, span, offsets) {
531
- let result = {
532
- minWidth: 0,
533
- maxWidth: 0
534
- };
535
- for (let i = 0; i < span; i++) {
536
- result.minWidth += node.table.widths[col + i]._minWidth + (i ? offsets.offsets[col + i] : 0);
537
- result.maxWidth += node.table.widths[col + i]._maxWidth + (i ? offsets.offsets[col + i] : 0);
538
- }
539
- return result;
540
- }
541
- function markSpans(rowData, col, span) {
542
- for (let i = 1; i < span; i++) {
543
- rowData[col + i] = {
544
- _span: true,
545
- _minWidth: 0,
546
- _maxWidth: 0,
547
- rowSpan: rowData[col].rowSpan
548
- };
549
- }
550
- }
551
- function markVSpans(table, row, col, span) {
552
- for (let i = 1; i < span; i++) {
553
- table.body[row + i][col] = {
554
- _span: true,
555
- _minWidth: 0,
556
- _maxWidth: 0,
557
- fillColor: table.body[row][col].fillColor,
558
- fillOpacity: table.body[row][col].fillOpacity
559
- };
560
- }
561
- }
562
- function extendTableWidths(node) {
563
- if (!node.table.widths) {
564
- node.table.widths = 'auto';
565
- }
566
- if ((0, _variableType.isString)(node.table.widths)) {
567
- node.table.widths = [node.table.widths];
568
- while (node.table.widths.length < node.table.body[0].length) {
569
- node.table.widths.push(node.table.widths[node.table.widths.length - 1]);
570
- }
571
- }
572
- for (let i = 0, l = node.table.widths.length; i < l; i++) {
573
- let w = node.table.widths[i];
574
- if ((0, _variableType.isNumber)(w) || (0, _variableType.isString)(w)) {
575
- node.table.widths[i] = {
576
- width: w
577
- };
578
- }
579
- }
580
- }
581
- }
582
- measureCanvas(node) {
583
- let w = 0;
584
- let h = 0;
585
- for (let i = 0, l = node.canvas.length; i < l; i++) {
586
- let vector = node.canvas[i];
587
- switch (vector.type) {
588
- case 'ellipse':
589
- w = Math.max(w, vector.x + vector.r1);
590
- h = Math.max(h, vector.y + vector.r2);
591
- break;
592
- case 'rect':
593
- w = Math.max(w, vector.x + vector.w);
594
- h = Math.max(h, vector.y + vector.h);
595
- break;
596
- case 'line':
597
- w = Math.max(w, vector.x1, vector.x2);
598
- h = Math.max(h, vector.y1, vector.y2);
599
- break;
600
- case 'polyline':
601
- for (let i2 = 0, l2 = vector.points.length; i2 < l2; i2++) {
602
- w = Math.max(w, vector.points[i2].x);
603
- h = Math.max(h, vector.points[i2].y);
604
- }
605
- break;
606
- }
607
- }
608
- node._minWidth = node._maxWidth = w;
609
- node._minHeight = node._maxHeight = h;
610
- node._alignment = this.styleStack.getProperty('alignment');
611
- return node;
612
- }
613
- measureQr(node) {
614
- node = _qrEnc.default.measure(node);
615
- node._alignment = this.styleStack.getProperty('alignment');
616
- return node;
617
- }
618
- measureAttachment(node) {
619
- node._width = node.width || 7;
620
- node._height = node.height || 18;
621
- return node;
622
- }
623
- }
624
- var _default = exports.default = DocMeasure;