pdfmake 0.3.2 → 0.3.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE +21 -21
  3. package/README.md +75 -78
  4. package/build/fonts/Roboto/Roboto-Italic.ttf +0 -0
  5. package/build/fonts/Roboto/Roboto-Medium.ttf +0 -0
  6. package/build/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
  7. package/build/fonts/Roboto/Roboto-Regular.ttf +0 -0
  8. package/build/fonts/Roboto.js +27 -0
  9. package/build/pdfmake.js +64813 -64584
  10. package/build/pdfmake.js.map +1 -1
  11. package/build/pdfmake.min.js +2 -2
  12. package/build/pdfmake.min.js.map +1 -1
  13. package/build/standard-fonts/Courier.js +27 -27
  14. package/build/standard-fonts/Helvetica.js +27 -27
  15. package/build/standard-fonts/Symbol.js +21 -21
  16. package/build/standard-fonts/Times.js +27 -27
  17. package/build/standard-fonts/ZapfDingbats.js +21 -21
  18. package/build/vfs_fonts.js +5 -5
  19. package/build-vfs.js +44 -44
  20. package/fonts/Roboto.js +8 -8
  21. package/js/3rd-party/svg-to-pdfkit/source.js +1 -1
  22. package/js/DocMeasure.js +11 -6
  23. package/js/DocumentContext.js +8 -3
  24. package/js/ElementWriter.js +42 -16
  25. package/js/LayoutBuilder.js +144 -78
  26. package/js/Line.js +16 -16
  27. package/js/OutputDocument.js +10 -10
  28. package/js/OutputDocumentServer.js +3 -3
  29. package/js/PDFDocument.js +3 -3
  30. package/js/PageElementWriter.js +15 -9
  31. package/js/Printer.js +28 -28
  32. package/js/Renderer.js +40 -8
  33. package/js/SVGMeasure.js +10 -10
  34. package/js/StyleContextStack.js +74 -51
  35. package/js/TableProcessor.js +14 -0
  36. package/js/TextBreaker.js +17 -17
  37. package/js/TextDecorator.js +12 -3
  38. package/js/TextInlines.js +34 -33
  39. package/js/base.js +4 -4
  40. package/js/browser-extensions/OutputDocumentBrowser.js +24 -24
  41. package/js/columnCalculator.js +2 -2
  42. package/js/helpers/node.js +47 -23
  43. package/js/helpers/variableType.js +18 -18
  44. package/js/qrEnc.js +38 -38
  45. package/js/virtual-fs.js +11 -11
  46. package/package.json +12 -12
  47. package/src/3rd-party/svg-to-pdfkit/LICENSE +9 -9
  48. package/src/3rd-party/svg-to-pdfkit/source.js +2745 -2745
  49. package/src/3rd-party/svg-to-pdfkit.js +3 -3
  50. package/src/DocMeasure.js +745 -738
  51. package/src/DocPreprocessor.js +283 -283
  52. package/src/DocumentContext.js +345 -338
  53. package/src/ElementWriter.js +441 -417
  54. package/src/LayoutBuilder.js +1336 -1258
  55. package/src/Line.js +114 -114
  56. package/src/OutputDocument.js +64 -64
  57. package/src/OutputDocumentServer.js +32 -32
  58. package/src/PDFDocument.js +174 -174
  59. package/src/PageElementWriter.js +187 -179
  60. package/src/PageSize.js +53 -53
  61. package/src/Printer.js +306 -306
  62. package/src/Renderer.js +445 -409
  63. package/src/SVGMeasure.js +109 -109
  64. package/src/StyleContextStack.js +208 -179
  65. package/src/TableProcessor.js +620 -602
  66. package/src/TextBreaker.js +168 -168
  67. package/src/TextDecorator.js +175 -161
  68. package/src/TextInlines.js +224 -223
  69. package/src/URLResolver.js +43 -43
  70. package/src/base.js +70 -70
  71. package/src/browser-extensions/OutputDocumentBrowser.js +80 -80
  72. package/src/browser-extensions/fonts/Roboto.js +27 -27
  73. package/src/browser-extensions/index.js +55 -55
  74. package/src/browser-extensions/pdfMake.js +1 -1
  75. package/src/browser-extensions/standard-fonts/Courier.js +27 -27
  76. package/src/browser-extensions/standard-fonts/Helvetica.js +27 -27
  77. package/src/browser-extensions/standard-fonts/Symbol.js +21 -21
  78. package/src/browser-extensions/standard-fonts/Times.js +27 -27
  79. package/src/browser-extensions/standard-fonts/ZapfDingbats.js +21 -21
  80. package/src/browser-extensions/virtual-fs-cjs.js +1 -1
  81. package/src/columnCalculator.js +154 -154
  82. package/src/helpers/node.js +134 -110
  83. package/src/helpers/tools.js +44 -44
  84. package/src/helpers/variableType.js +50 -50
  85. package/src/index.js +16 -16
  86. package/src/qrEnc.js +796 -796
  87. package/src/standardPageSizes.js +52 -52
  88. package/src/tableLayouts.js +100 -100
  89. package/src/virtual-fs.js +66 -66
  90. package/standard-fonts/Courier.js +8 -8
  91. package/standard-fonts/Helvetica.js +8 -8
  92. package/standard-fonts/Symbol.js +5 -5
  93. package/standard-fonts/Times.js +8 -8
  94. package/standard-fonts/ZapfDingbats.js +5 -5
package/js/Line.js CHANGED
@@ -3,8 +3,8 @@
3
3
  exports.__esModule = true;
4
4
  exports.default = void 0;
5
5
  class Line {
6
- /**
7
- * @param {number} maxWidth Maximum width this line can have
6
+ /**
7
+ * @param {number} maxWidth Maximum width this line can have
8
8
  */
9
9
  constructor(maxWidth) {
10
10
  this.maxWidth = maxWidth;
@@ -14,8 +14,8 @@ class Line {
14
14
  this.inlines = [];
15
15
  }
16
16
 
17
- /**
18
- * @param {object} inline
17
+ /**
18
+ * @param {object} inline
19
19
  */
20
20
  addInline(inline) {
21
21
  if (this.inlines.length === 0) {
@@ -30,8 +30,8 @@ class Line {
30
30
  }
31
31
  }
32
32
 
33
- /**
34
- * @returns {number}
33
+ /**
34
+ * @returns {number}
35
35
  */
36
36
  getHeight() {
37
37
  let max = 0;
@@ -41,8 +41,8 @@ class Line {
41
41
  return max;
42
42
  }
43
43
 
44
- /**
45
- * @returns {number}
44
+ /**
45
+ * @returns {number}
46
46
  */
47
47
  getAscenderHeight() {
48
48
  let y = 0;
@@ -52,24 +52,24 @@ class Line {
52
52
  return y;
53
53
  }
54
54
 
55
- /**
56
- * @returns {number}
55
+ /**
56
+ * @returns {number}
57
57
  */
58
58
  getWidth() {
59
59
  return this.inlineWidths - this.leadingCut - this.trailingCut;
60
60
  }
61
61
 
62
- /**
63
- * @returns {number}
62
+ /**
63
+ * @returns {number}
64
64
  */
65
65
  getAvailableWidth() {
66
66
  return this.maxWidth - this.getWidth();
67
67
  }
68
68
 
69
- /**
70
- * @param {object} inline
71
- * @param {Array} nextInlines
72
- * @returns {boolean}
69
+ /**
70
+ * @param {object} inline
71
+ * @param {Array} nextInlines
72
+ * @returns {boolean}
73
73
  */
74
74
  hasEnoughSpaceForInline(inline, nextInlines = []) {
75
75
  if (this.inlines.length === 0) {
@@ -3,8 +3,8 @@
3
3
  exports.__esModule = true;
4
4
  exports.default = void 0;
5
5
  class OutputDocument {
6
- /**
7
- * @param {Promise<object>} pdfDocumentPromise
6
+ /**
7
+ * @param {Promise<object>} pdfDocumentPromise
8
8
  */
9
9
  constructor(pdfDocumentPromise) {
10
10
  this.bufferSize = 1073741824;
@@ -12,15 +12,15 @@ class OutputDocument {
12
12
  this.bufferPromise = null;
13
13
  }
14
14
 
15
- /**
16
- * @returns {Promise<object>}
15
+ /**
16
+ * @returns {Promise<object>}
17
17
  */
18
18
  getStream() {
19
19
  return this.pdfDocumentPromise;
20
20
  }
21
21
 
22
- /**
23
- * @returns {Promise<Buffer>}
22
+ /**
23
+ * @returns {Promise<Buffer>}
24
24
  */
25
25
  getBuffer() {
26
26
  const getBufferInternal = async () => {
@@ -45,16 +45,16 @@ class OutputDocument {
45
45
  return this.bufferPromise;
46
46
  }
47
47
 
48
- /**
49
- * @returns {Promise<string>}
48
+ /**
49
+ * @returns {Promise<string>}
50
50
  */
51
51
  async getBase64() {
52
52
  const buffer = await this.getBuffer();
53
53
  return buffer.toString('base64');
54
54
  }
55
55
 
56
- /**
57
- * @returns {Promise<string>}
56
+ /**
57
+ * @returns {Promise<string>}
58
58
  */
59
59
  async getDataUrl() {
60
60
  const data = await this.getBase64();
@@ -6,9 +6,9 @@ var _OutputDocument = _interopRequireDefault(require("./OutputDocument"));
6
6
  var _fs = _interopRequireDefault(require("fs"));
7
7
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
8
  class OutputDocumentServer extends _OutputDocument.default {
9
- /**
10
- * @param {string} filename
11
- * @returns {Promise}
9
+ /**
10
+ * @param {string} filename
11
+ * @returns {Promise}
12
12
  */
13
13
  async write(filename) {
14
14
  const stream = await this.getStream();
package/js/PDFDocument.js CHANGED
@@ -102,9 +102,9 @@ class PDFDocument extends _pdfkit.default {
102
102
  return image;
103
103
  }
104
104
 
105
- /**
106
- * @param {Array} color pdfmake format: [<pattern name>, <color>]
107
- * @returns {Array} pdfkit format: [<pattern object>, <color>]
105
+ /**
106
+ * @param {Array} color pdfmake format: [<pattern name>, <color>]
107
+ * @returns {Array} pdfkit format: [<pattern object>, <color>]
108
108
  */
109
109
  providePattern(color) {
110
110
  if (Array.isArray(color) && color.length === 2) {
@@ -6,17 +6,17 @@ var _ElementWriter = _interopRequireDefault(require("./ElementWriter"));
6
6
  var _PageSize = require("./PageSize");
7
7
  var _DocumentContext = _interopRequireDefault(require("./DocumentContext"));
8
8
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- /**
10
- * An extended ElementWriter which can handle:
11
- * - page-breaks (it adds new pages when there's not enough space left),
12
- * - repeatable fragments (like table-headers, which are repeated everytime
13
- * a page-break occurs)
14
- * - transactions (used for unbreakable-blocks when we want to make sure
15
- * whole block will be rendered on the same page)
9
+ /**
10
+ * An extended ElementWriter which can handle:
11
+ * - page-breaks (it adds new pages when there's not enough space left),
12
+ * - repeatable fragments (like table-headers, which are repeated everytime
13
+ * a page-break occurs)
14
+ * - transactions (used for unbreakable-blocks when we want to make sure
15
+ * whole block will be rendered on the same page)
16
16
  */
17
17
  class PageElementWriter extends _ElementWriter.default {
18
- /**
19
- * @param {DocumentContext} context
18
+ /**
19
+ * @param {DocumentContext} context
20
20
  */
21
21
  constructor(context) {
22
22
  super(context);
@@ -50,6 +50,12 @@ class PageElementWriter extends _ElementWriter.default {
50
50
  endClip() {
51
51
  return super.endClip();
52
52
  }
53
+ beginVerticalAlignment(verticalAlignment) {
54
+ return super.beginVerticalAlignment(verticalAlignment);
55
+ }
56
+ endVerticalAlignment(verticalAlignment) {
57
+ return super.endVerticalAlignment(verticalAlignment);
58
+ }
53
59
  addFragment(fragment, useBlockXOffset, useBlockYOffset, dontUpdateContextPosition) {
54
60
  return this._fitOnPage(() => super.addFragment(fragment, useBlockXOffset, useBlockYOffset, dontUpdateContextPosition));
55
61
  }
package/js/Printer.js CHANGED
@@ -11,26 +11,26 @@ var _Renderer = _interopRequireDefault(require("./Renderer"));
11
11
  var _variableType = require("./helpers/variableType");
12
12
  var _tools = require("./helpers/tools");
13
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
- /**
15
- * Printer which turns document definition into a pdf
16
- *
17
- * @example
18
- * var fontDescriptors = {
19
- * Roboto: {
20
- * normal: 'fonts/Roboto-Regular.ttf',
21
- * bold: 'fonts/Roboto-Medium.ttf',
22
- * italics: 'fonts/Roboto-Italic.ttf',
23
- * bolditalics: 'fonts/Roboto-MediumItalic.ttf'
24
- * }
25
- * };
26
- *
27
- * var printer = new PdfPrinter(fontDescriptors);
14
+ /**
15
+ * Printer which turns document definition into a pdf
16
+ *
17
+ * @example
18
+ * var fontDescriptors = {
19
+ * Roboto: {
20
+ * normal: 'fonts/Roboto-Regular.ttf',
21
+ * bold: 'fonts/Roboto-Medium.ttf',
22
+ * italics: 'fonts/Roboto-Italic.ttf',
23
+ * bolditalics: 'fonts/Roboto-MediumItalic.ttf'
24
+ * }
25
+ * };
26
+ *
27
+ * var printer = new PdfPrinter(fontDescriptors);
28
28
  */
29
29
  class PdfPrinter {
30
- /**
31
- * @param {object} fontDescriptors font definition dictionary
32
- * @param {object} virtualfs
33
- * @param {object} urlResolver
30
+ /**
31
+ * @param {object} fontDescriptors font definition dictionary
32
+ * @param {object} virtualfs
33
+ * @param {object} urlResolver
34
34
  */
35
35
  constructor(fontDescriptors, virtualfs = null, urlResolver = null) {
36
36
  this.fontDescriptors = fontDescriptors;
@@ -38,13 +38,13 @@ class PdfPrinter {
38
38
  this.urlResolver = urlResolver;
39
39
  }
40
40
 
41
- /**
42
- * Executes layout engine for the specified document and renders it into a pdfkit document
43
- * ready to be saved.
44
- *
45
- * @param {object} docDefinition
46
- * @param {object} options
47
- * @returns {Promise<PDFDocument>} resolved promise return a pdfkit document
41
+ /**
42
+ * Executes layout engine for the specified document and renders it into a pdfkit document
43
+ * ready to be saved.
44
+ *
45
+ * @param {object} docDefinition
46
+ * @param {object} options
47
+ * @returns {Promise<PDFDocument>} resolved promise return a pdfkit document
48
48
  */
49
49
  async createPdfKitDocument(docDefinition, options = {}) {
50
50
  await this.resolveUrls(docDefinition);
@@ -109,9 +109,9 @@ class PdfPrinter {
109
109
  return this.pdfKitDoc;
110
110
  }
111
111
 
112
- /**
113
- * @param {object} docDefinition
114
- * @returns {Promise}
112
+ /**
113
+ * @param {object} docDefinition
114
+ * @returns {Promise}
115
115
  */
116
116
  async resolveUrls(docDefinition) {
117
117
  const getExtendedUrl = url => {
package/js/Renderer.js CHANGED
@@ -19,14 +19,14 @@ const findFont = (fonts, requiredFonts, defaultFont) => {
19
19
  return defaultFont;
20
20
  };
21
21
 
22
- /**
23
- * Shift the "y" height of the text baseline up or down (superscript or subscript,
24
- * respectively). The exact shift can / should be changed according to standard
25
- * conventions.
26
- *
27
- * @param {number} y
28
- * @param {object} inline
29
- * @returns {number}
22
+ /**
23
+ * Shift the "y" height of the text baseline up or down (superscript or subscript,
24
+ * respectively). The exact shift can / should be changed according to standard
25
+ * conventions.
26
+ *
27
+ * @param {number} y
28
+ * @param {object} inline
29
+ * @returns {number}
30
30
  */
31
31
  const offsetText = (y, inline) => {
32
32
  let newY = y;
@@ -82,6 +82,12 @@ class Renderer {
82
82
  case 'endClip':
83
83
  this.endClip();
84
84
  break;
85
+ case 'beginVerticalAlignment':
86
+ this.beginVerticalAlignment(item.item);
87
+ break;
88
+ case 'endVerticalAlignment':
89
+ this.endVerticalAlignment(item.item);
90
+ break;
85
91
  }
86
92
  renderedItems++;
87
93
  if (this.progressCallback) {
@@ -364,6 +370,32 @@ class Renderer {
364
370
  endClip() {
365
371
  this.pdfDocument.restore();
366
372
  }
373
+ beginVerticalAlignment(item) {
374
+ if (item.isCellContentMultiPage) {
375
+ return;
376
+ }
377
+ switch (item.verticalAlignment) {
378
+ case 'middle':
379
+ this.pdfDocument.save();
380
+ this.pdfDocument.translate(0, -(item.getNodeHeight() - item.getViewHeight()) / 2);
381
+ break;
382
+ case 'bottom':
383
+ this.pdfDocument.save();
384
+ this.pdfDocument.translate(0, -(item.getNodeHeight() - item.getViewHeight()));
385
+ break;
386
+ }
387
+ }
388
+ endVerticalAlignment(item) {
389
+ if (item.isCellContentMultiPage) {
390
+ return;
391
+ }
392
+ switch (item.verticalAlignment) {
393
+ case 'middle':
394
+ case 'bottom':
395
+ this.pdfDocument.restore();
396
+ break;
397
+ }
398
+ }
367
399
  renderWatermark(page) {
368
400
  let watermark = page.watermark;
369
401
  this.pdfDocument.fill(watermark.color);
package/js/SVGMeasure.js CHANGED
@@ -4,11 +4,11 @@ exports.__esModule = true;
4
4
  exports.default = void 0;
5
5
  var _xmldoc = require("xmldoc");
6
6
  var _variableType = require("./helpers/variableType");
7
- /**
8
- * Strip unit postfix, parse number, but return undefined instead of NaN for bad input
9
- *
10
- * @param {string} textVal
11
- * @returns {?number}
7
+ /**
8
+ * Strip unit postfix, parse number, but return undefined instead of NaN for bad input
9
+ *
10
+ * @param {string} textVal
11
+ * @returns {?number}
12
12
  */
13
13
  const stripUnits = textVal => {
14
14
  let n = parseFloat(textVal);
@@ -18,11 +18,11 @@ const stripUnits = textVal => {
18
18
  return n;
19
19
  };
20
20
 
21
- /**
22
- * Make sure it's valid XML and the root tag is <svg/>, returns xmldoc DOM
23
- *
24
- * @param {string} svgString
25
- * @returns {object}
21
+ /**
22
+ * Make sure it's valid XML and the root tag is <svg/>, returns xmldoc DOM
23
+ *
24
+ * @param {string} svgString
25
+ * @returns {object}
26
26
  */
27
27
  const parseSVG = svgString => {
28
28
  let doc;
@@ -3,13 +3,13 @@
3
3
  exports.__esModule = true;
4
4
  exports.default = void 0;
5
5
  var _variableType = require("./helpers/variableType");
6
- /**
7
- * Used for style inheritance and style overrides
6
+ /**
7
+ * Used for style inheritance and style overrides
8
8
  */
9
9
  class StyleContextStack {
10
- /**
11
- * @param {object} styleDictionary named styles dictionary
12
- * @param {object} defaultStyle optional default style definition
10
+ /**
11
+ * @param {object} styleDictionary named styles dictionary
12
+ * @param {object} defaultStyle optional default style definition
13
13
  */
14
14
  constructor(styleDictionary, defaultStyle = {}) {
15
15
  this.styleDictionary = styleDictionary;
@@ -17,10 +17,10 @@ class StyleContextStack {
17
17
  this.styleOverrides = [];
18
18
  }
19
19
 
20
- /**
21
- * Creates cloned version of current stack
22
- *
23
- * @returns {StyleContextStack} current stack snapshot
20
+ /**
21
+ * Creates cloned version of current stack
22
+ *
23
+ * @returns {StyleContextStack} current stack snapshot
24
24
  */
25
25
  clone() {
26
26
  let stack = new StyleContextStack(this.styleDictionary, this.defaultStyle);
@@ -30,21 +30,21 @@ class StyleContextStack {
30
30
  return stack;
31
31
  }
32
32
 
33
- /**
34
- * Pushes style-name or style-overrides-object onto the stack for future evaluation
35
- *
36
- * @param {string|object} styleNameOrOverride style-name (referring to styleDictionary) or
37
- * a new dictionary defining overriding properties
33
+ /**
34
+ * Pushes style-name or style-overrides-object onto the stack for future evaluation
35
+ *
36
+ * @param {string|object} styleNameOrOverride style-name (referring to styleDictionary) or
37
+ * a new dictionary defining overriding properties
38
38
  */
39
39
  push(styleNameOrOverride) {
40
40
  this.styleOverrides.push(styleNameOrOverride);
41
41
  }
42
42
 
43
- /**
44
- * Removes last style-name or style-overrides-object from the stack
45
- *
46
- * @param {number} howMany optional number of elements to be popped (if not specified,
47
- * one element will be removed from the stack)
43
+ /**
44
+ * Removes last style-name or style-overrides-object from the stack
45
+ *
46
+ * @param {number} howMany optional number of elements to be popped (if not specified,
47
+ * one element will be removed from the stack)
48
48
  */
49
49
  pop(howMany = 1) {
50
50
  while (howMany-- > 0) {
@@ -52,13 +52,13 @@ class StyleContextStack {
52
52
  }
53
53
  }
54
54
 
55
- /**
56
- * Creates a set of named styles or/and a style-overrides-object based on the item,
57
- * pushes those elements onto the stack for future evaluation and returns the number
58
- * of elements pushed, so they can be easily popped then.
59
- *
60
- * @param {object} item - an object with optional style property and/or style overrides
61
- * @returns {number} the number of items pushed onto the stack
55
+ /**
56
+ * Creates a set of named styles or/and a style-overrides-object based on the item,
57
+ * pushes those elements onto the stack for future evaluation and returns the number
58
+ * of elements pushed, so they can be easily popped then.
59
+ *
60
+ * @param {object} item - an object with optional style property and/or style overrides
61
+ * @returns {number} the number of items pushed onto the stack
62
62
  */
63
63
  autopush(item) {
64
64
  if ((0, _variableType.isString)(item)) {
@@ -85,13 +85,13 @@ class StyleContextStack {
85
85
  return styleNames.length + 1;
86
86
  }
87
87
 
88
- /**
89
- * Automatically pushes elements onto the stack, using autopush based on item,
90
- * executes callback and then pops elements back. Returns value returned by callback
91
- *
92
- * @param {object} item - an object with optional style property and/or style overrides
93
- * @param {Function} callback to be called between autopush and pop
94
- * @returns {object} value returned by callback
88
+ /**
89
+ * Automatically pushes elements onto the stack, using autopush based on item,
90
+ * executes callback and then pops elements back. Returns value returned by callback
91
+ *
92
+ * @param {object} item - an object with optional style property and/or style overrides
93
+ * @param {Function} callback to be called between autopush and pop
94
+ * @returns {object} value returned by callback
95
95
  */
96
96
  auto(item, callback) {
97
97
  let pushedItems = this.autopush(item);
@@ -102,21 +102,44 @@ class StyleContextStack {
102
102
  return result;
103
103
  }
104
104
 
105
- /**
106
- * Evaluates stack and returns value of a named property
107
- *
108
- * @param {string} property - property name
109
- * @returns {?any} property value or null if not found
105
+ /**
106
+ * Evaluates stack and returns value of a named property
107
+ *
108
+ * @param {string} property - property name
109
+ * @returns {?any} property value or null if not found
110
110
  */
111
111
  getProperty(property) {
112
+ const getStylePropertyFromStyle = (styleName, property, visited = new Set()) => {
113
+ if (visited.has(styleName)) {
114
+ return undefined;
115
+ }
116
+ visited.add(styleName);
117
+ const style = this.styleDictionary[styleName];
118
+ if (!style) {
119
+ return undefined;
120
+ }
121
+ if ((0, _variableType.isValue)(style[property])) {
122
+ return style[property];
123
+ }
124
+ if (style.extends) {
125
+ let parents = Array.isArray(style.extends) ? style.extends : [style.extends];
126
+ for (let i = parents.length - 1; i >= 0; i--) {
127
+ let value = getStylePropertyFromStyle(parents[i], property, visited);
128
+ if ((0, _variableType.isValue)(value)) {
129
+ return value;
130
+ }
131
+ }
132
+ }
133
+ return undefined;
134
+ };
112
135
  if (this.styleOverrides) {
113
136
  for (let i = this.styleOverrides.length - 1; i >= 0; i--) {
114
137
  let item = this.styleOverrides[i];
115
138
  if ((0, _variableType.isString)(item)) {
116
139
  // named-style-override
117
- let style = this.styleDictionary[item];
118
- if (style && (0, _variableType.isValue)(style[property])) {
119
- return style[property];
140
+ let value = getStylePropertyFromStyle(item, property);
141
+ if ((0, _variableType.isValue)(value)) {
142
+ return value;
120
143
  }
121
144
  } else if ((0, _variableType.isValue)(item[property])) {
122
145
  // style-overrides-object
@@ -127,12 +150,12 @@ class StyleContextStack {
127
150
  return this.defaultStyle && this.defaultStyle[property];
128
151
  }
129
152
 
130
- /**
131
- * @param {object} item
132
- * @param {StyleContextStack} styleContextStack
133
- * @param {string} property
134
- * @param {any} defaultValue
135
- * @returns {any}
153
+ /**
154
+ * @param {object} item
155
+ * @param {StyleContextStack} styleContextStack
156
+ * @param {string} property
157
+ * @param {any} defaultValue
158
+ * @returns {any}
136
159
  */
137
160
  static getStyleProperty(item, styleContextStack, property, defaultValue) {
138
161
  let value;
@@ -149,10 +172,10 @@ class StyleContextStack {
149
172
  return (0, _variableType.isValue)(value) ? value : defaultValue;
150
173
  }
151
174
 
152
- /**
153
- * @param {object} source
154
- * @param {object} destination
155
- * @returns {object}
175
+ /**
176
+ * @param {object} source
177
+ * @param {object} destination
178
+ * @returns {object}
156
179
  */
157
180
  static copyStyle(source = {}, destination = {}) {
158
181
  // TODO: default style to source
@@ -145,6 +145,7 @@ class TableProcessor {
145
145
  this._tableTopBorderY = writer.context().y;
146
146
  writer.context().moveDown(this.topLineWidth);
147
147
  }
148
+ this.rowTopPageY = writer.context().y + this.rowPaddingTop;
148
149
  if (this.dontBreakRows && rowIndex > 0) {
149
150
  writer.beginUnbreakableBlock();
150
151
  }
@@ -441,6 +442,19 @@ class TableProcessor {
441
442
  this.drawVerticalLine(xs[i].x, y1 - hzLineOffset, y2 + this.bottomLineWidth, xs[i].index, writer, rowIndex, xs[i - 1] ? xs[i - 1].index : null);
442
443
  }
443
444
  if (i < l - 1) {
445
+ body[rowIndex][colIndex]._willBreak = body[rowIndex][colIndex]._willBreak ?? willBreak;
446
+ if (body[rowIndex][colIndex]._bottomY === undefined) {
447
+ let bottomY = this.dontBreakRows ? y2 + this.bottomLineWidth : y2 + this.bottomLineWidth / 2;
448
+ if (willBreak || this.dontBreakRows) {
449
+ bottomY = bottomY - this.rowPaddingBottom;
450
+ }
451
+ body[rowIndex][colIndex]._bottomY = bottomY - this.reservedAtBottom;
452
+ }
453
+ body[rowIndex][colIndex]._rowTopPageY = this.rowTopPageY;
454
+ if (this.dontBreakRows) {
455
+ body[rowIndex][colIndex]._rowTopPageYPadding = this.rowPaddingTop;
456
+ }
457
+ body[rowIndex][colIndex]._lastPageNumber = ys[yi].page + 1;
444
458
  let fillColor = body[rowIndex][colIndex].fillColor;
445
459
  let fillOpacity = body[rowIndex][colIndex].fillOpacity;
446
460
  if (!fillColor) {
package/js/TextBreaker.js CHANGED
@@ -6,11 +6,11 @@ var _linebreak = _interopRequireDefault(require("linebreak"));
6
6
  var _variableType = require("./helpers/variableType");
7
7
  var _StyleContextStack = _interopRequireDefault(require("./StyleContextStack"));
8
8
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- /**
10
- * @param {string} text
11
- * @param {boolean} noWrap
12
- * @param {boolean} breakAll
13
- * @returns {Array}
9
+ /**
10
+ * @param {string} text
11
+ * @param {boolean} noWrap
12
+ * @param {boolean} breakAll
13
+ * @returns {Array}
14
14
  */
15
15
  const splitWords = (text, noWrap, breakAll = false) => {
16
16
  let words = [];
@@ -67,10 +67,10 @@ const splitWords = (text, noWrap, breakAll = false) => {
67
67
  return words;
68
68
  };
69
69
 
70
- /**
71
- * @param {Array} words
72
- * @param {boolean} noWrap
73
- * @returns {?string}
70
+ /**
71
+ * @param {Array} words
72
+ * @param {boolean} noWrap
73
+ * @returns {?string}
74
74
  */
75
75
  const getFirstWord = (words, noWrap) => {
76
76
  let word = words[0];
@@ -88,10 +88,10 @@ const getFirstWord = (words, noWrap) => {
88
88
  return word.text;
89
89
  };
90
90
 
91
- /**
92
- * @param {Array} words
93
- * @param {boolean} noWrap
94
- * @returns {?string}
91
+ /**
92
+ * @param {Array} words
93
+ * @param {boolean} noWrap
94
+ * @returns {?string}
95
95
  */
96
96
  const getLastWord = (words, noWrap) => {
97
97
  let word = words[words.length - 1];
@@ -112,10 +112,10 @@ const getLastWord = (words, noWrap) => {
112
112
  return word.text;
113
113
  };
114
114
  class TextBreaker {
115
- /**
116
- * @param {string|Array} texts
117
- * @param {StyleContextStack} styleContextStack
118
- * @returns {Array}
115
+ /**
116
+ * @param {string|Array} texts
117
+ * @param {StyleContextStack} styleContextStack
118
+ * @returns {Array}
119
119
  */
120
120
  getBreaks(texts, styleContextStack) {
121
121
  let results = [];