pdfmake 0.2.13 → 0.3.0-beta.10

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 (136) hide show
  1. package/CHANGELOG.md +23 -41
  2. package/README.md +11 -7
  3. package/build/pdfmake.js +22291 -23202
  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/build/standard-fonts/Courier.js +27 -0
  8. package/build/standard-fonts/Helvetica.js +27 -0
  9. package/build/standard-fonts/Symbol.js +21 -0
  10. package/build/standard-fonts/Times.js +27 -0
  11. package/build/standard-fonts/ZapfDingbats.js +21 -0
  12. package/build/vfs_fonts.js +2 -2
  13. package/build-vfs.js +2 -2
  14. package/eslint.config.mjs +52 -0
  15. package/fonts/Roboto/Roboto-Italic.ttf +0 -0
  16. package/fonts/Roboto/Roboto-Medium.ttf +0 -0
  17. package/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
  18. package/fonts/Roboto/Roboto-Regular.ttf +0 -0
  19. package/fonts/Roboto.js +8 -0
  20. package/js/3rd-party/svg-to-pdfkit/source.js +3626 -0
  21. package/js/3rd-party/svg-to-pdfkit.js +7 -0
  22. package/js/DocMeasure.js +626 -0
  23. package/js/DocPreprocessor.js +238 -0
  24. package/js/DocumentContext.js +288 -0
  25. package/js/ElementWriter.js +342 -0
  26. package/js/LayoutBuilder.js +881 -0
  27. package/js/Line.js +105 -0
  28. package/js/OutputDocument.js +76 -0
  29. package/js/OutputDocumentServer.js +27 -0
  30. package/js/PDFDocument.js +144 -0
  31. package/js/PageElementWriter.js +140 -0
  32. package/js/PageSize.js +74 -0
  33. package/js/Printer.js +291 -0
  34. package/js/Renderer.js +375 -0
  35. package/js/SVGMeasure.js +69 -0
  36. package/js/StyleContextStack.js +164 -0
  37. package/js/TableProcessor.js +524 -0
  38. package/js/TextBreaker.js +139 -0
  39. package/js/TextDecorator.js +143 -0
  40. package/js/TextInlines.js +206 -0
  41. package/js/URLResolver.js +73 -0
  42. package/js/base.js +52 -0
  43. package/js/browser-extensions/OutputDocumentBrowser.js +118 -0
  44. package/js/browser-extensions/URLBrowserResolver.js +76 -0
  45. package/js/browser-extensions/fonts/Roboto.js +38 -0
  46. package/js/browser-extensions/index.js +53 -0
  47. package/js/browser-extensions/pdfMake.js +3 -0
  48. package/js/browser-extensions/standard-fonts/Courier.js +38 -0
  49. package/js/browser-extensions/standard-fonts/Helvetica.js +38 -0
  50. package/js/browser-extensions/standard-fonts/Symbol.js +23 -0
  51. package/js/browser-extensions/standard-fonts/Times.js +38 -0
  52. package/js/browser-extensions/standard-fonts/ZapfDingbats.js +23 -0
  53. package/js/browser-extensions/virtual-fs-cjs.js +3 -0
  54. package/js/columnCalculator.js +148 -0
  55. package/js/helpers/node.js +98 -0
  56. package/js/helpers/tools.js +40 -0
  57. package/js/helpers/variableType.js +59 -0
  58. package/js/index.js +15 -0
  59. package/js/qrEnc.js +721 -0
  60. package/js/standardPageSizes.js +56 -0
  61. package/js/tableLayouts.js +98 -0
  62. package/js/virtual-fs.js +60 -0
  63. package/package.json +34 -28
  64. package/src/3rd-party/svg-to-pdfkit.js +2 -2
  65. package/src/DocMeasure.js +707 -0
  66. package/src/DocPreprocessor.js +264 -0
  67. package/src/DocumentContext.js +324 -0
  68. package/src/ElementWriter.js +405 -0
  69. package/src/LayoutBuilder.js +997 -0
  70. package/src/Line.js +114 -0
  71. package/src/OutputDocument.js +78 -0
  72. package/src/OutputDocumentServer.js +26 -0
  73. package/src/PDFDocument.js +174 -0
  74. package/src/PageElementWriter.js +160 -0
  75. package/src/PageSize.js +53 -0
  76. package/src/Printer.js +306 -0
  77. package/src/Renderer.js +405 -0
  78. package/src/SVGMeasure.js +79 -0
  79. package/src/StyleContextStack.js +175 -0
  80. package/src/TableProcessor.js +580 -0
  81. package/src/TextBreaker.js +149 -0
  82. package/src/TextDecorator.js +161 -0
  83. package/src/TextInlines.js +223 -0
  84. package/src/URLResolver.js +77 -0
  85. package/src/base.js +61 -0
  86. package/src/browser-extensions/OutputDocumentBrowser.js +117 -0
  87. package/src/browser-extensions/URLBrowserResolver.js +45 -57
  88. package/src/browser-extensions/fonts/Roboto.js +27 -0
  89. package/src/browser-extensions/index.js +55 -0
  90. package/src/browser-extensions/pdfMake.js +1 -329
  91. package/src/browser-extensions/standard-fonts/Courier.js +27 -0
  92. package/src/browser-extensions/standard-fonts/Helvetica.js +27 -0
  93. package/src/browser-extensions/standard-fonts/Symbol.js +21 -0
  94. package/src/browser-extensions/standard-fonts/Times.js +27 -0
  95. package/src/browser-extensions/standard-fonts/ZapfDingbats.js +21 -0
  96. package/src/browser-extensions/virtual-fs-cjs.js +1 -0
  97. package/src/columnCalculator.js +35 -38
  98. package/src/helpers/node.js +110 -0
  99. package/src/helpers/tools.js +39 -0
  100. package/src/helpers/variableType.js +50 -0
  101. package/src/index.js +16 -0
  102. package/src/qrEnc.js +15 -10
  103. package/src/standardPageSizes.js +1 -3
  104. package/src/tableLayouts.js +100 -0
  105. package/src/virtual-fs.js +66 -0
  106. package/standard-fonts/Courier.js +8 -0
  107. package/standard-fonts/Helvetica.js +9 -0
  108. package/standard-fonts/Symbol.js +5 -0
  109. package/standard-fonts/Times.js +8 -0
  110. package/standard-fonts/ZapfDingbats.js +5 -0
  111. package/.idea/codeStyles/Project.xml +0 -7
  112. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  113. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  114. package/.idea/misc.xml +0 -6
  115. package/.idea/modules.xml +0 -8
  116. package/.idea/pdfmake.iml +0 -11
  117. package/.idea/vcs.xml +0 -6
  118. package/src/browser-extensions/virtual-fs.js +0 -55
  119. package/src/docMeasure.js +0 -810
  120. package/src/docPreprocessor.js +0 -255
  121. package/src/documentContext.js +0 -328
  122. package/src/elementWriter.js +0 -333
  123. package/src/fontProvider.js +0 -68
  124. package/src/helpers.js +0 -138
  125. package/src/imageMeasure.js +0 -55
  126. package/src/layoutBuilder.js +0 -989
  127. package/src/line.js +0 -91
  128. package/src/pageElementWriter.js +0 -174
  129. package/src/pdfKitEngine.js +0 -21
  130. package/src/printer.js +0 -710
  131. package/src/styleContextStack.js +0 -138
  132. package/src/svgMeasure.js +0 -70
  133. package/src/tableProcessor.js +0 -584
  134. package/src/textDecorator.js +0 -157
  135. package/src/textTools.js +0 -373
  136. package/src/traversalTracker.js +0 -47
@@ -0,0 +1,27 @@
1
+ var fs = require('fs');
2
+
3
+ var fontContainer = {
4
+ vfs: {
5
+ 'data/Helvetica.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Helvetica.afm', 'utf8'), encoding: 'utf8' },
6
+ 'data/Helvetica-Bold.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Helvetica-Bold.afm', 'utf8'), encoding: 'utf8' },
7
+ 'data/Helvetica-Oblique.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Helvetica-Oblique.afm', 'utf8'), encoding: 'utf8' },
8
+ 'data/Helvetica-BoldOblique.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Helvetica-BoldOblique.afm', 'utf8'), encoding: 'utf8' }
9
+ },
10
+ fonts: {
11
+ Helvetica: {
12
+ normal: 'Helvetica',
13
+ bold: 'Helvetica-Bold',
14
+ italics: 'Helvetica-Oblique',
15
+ bolditalics: 'Helvetica-BoldOblique'
16
+ }
17
+ }
18
+ };
19
+
20
+ var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : this;
21
+ if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
22
+ _global.pdfMake.addFontContainer(fontContainer);
23
+ }
24
+
25
+ if (typeof module !== 'undefined') {
26
+ module.exports = fontContainer;
27
+ }
@@ -0,0 +1,21 @@
1
+ var fs = require('fs');
2
+
3
+ var fontContainer = {
4
+ vfs: {
5
+ 'data/Symbol.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Symbol.afm', 'utf8'), encoding: 'utf8' }
6
+ },
7
+ fonts: {
8
+ Symbol: {
9
+ normal: 'Symbol'
10
+ }
11
+ }
12
+ };
13
+
14
+ var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : this;
15
+ if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
16
+ _global.pdfMake.addFontContainer(fontContainer);
17
+ }
18
+
19
+ if (typeof module !== 'undefined') {
20
+ module.exports = fontContainer;
21
+ }
@@ -0,0 +1,27 @@
1
+ var fs = require('fs');
2
+
3
+ var fontContainer = {
4
+ vfs: {
5
+ 'data/Times-Roman.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Times-Roman.afm', 'utf8'), encoding: 'utf8' },
6
+ 'data/Times-Bold.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Times-Bold.afm', 'utf8'), encoding: 'utf8' },
7
+ 'data/Times-Italic.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Times-Italic.afm', 'utf8'), encoding: 'utf8' },
8
+ 'data/Times-BoldItalic.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Times-BoldItalic.afm', 'utf8'), encoding: 'utf8' }
9
+ },
10
+ fonts: {
11
+ Times: {
12
+ normal: 'Times-Roman',
13
+ bold: 'Times-Bold',
14
+ italics: 'Times-Italic',
15
+ bolditalics: 'Times-BoldItalic'
16
+ }
17
+ }
18
+ };
19
+
20
+ var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : this;
21
+ if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
22
+ _global.pdfMake.addFontContainer(fontContainer);
23
+ }
24
+
25
+ if (typeof module !== 'undefined') {
26
+ module.exports = fontContainer;
27
+ }
@@ -0,0 +1,21 @@
1
+ var fs = require('fs');
2
+
3
+ var fontContainer = {
4
+ vfs: {
5
+ 'data/ZapfDingbats.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/ZapfDingbats.afm', 'utf8'), encoding: 'utf8' }
6
+ },
7
+ fonts: {
8
+ ZapfDingbats: {
9
+ normal: 'ZapfDingbats'
10
+ }
11
+ }
12
+ };
13
+
14
+ var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : this;
15
+ if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
16
+ _global.pdfMake.addFontContainer(fontContainer);
17
+ }
18
+
19
+ if (typeof module !== 'undefined') {
20
+ module.exports = fontContainer;
21
+ }
@@ -0,0 +1 @@
1
+ module.exports = require('../virtual-fs').default;
@@ -1,17 +1,16 @@
1
- 'use strict';
2
-
3
- var isString = require('./helpers').isString;
1
+ import { isString } from './helpers/variableType';
4
2
 
5
3
  function buildColumnWidths(columns, availableWidth, offsetTotal = 0, tableNode) {
6
- var autoColumns = [],
7
- autoMin = 0, autoMax = 0,
8
- starColumns = [],
9
- starMaxMin = 0,
10
- starMaxMax = 0,
11
- fixedColumns = [],
12
- initial_availableWidth = availableWidth;
13
-
14
- columns.forEach(function (column) {
4
+ let autoColumns = [];
5
+ let autoMin = 0;
6
+ let autoMax = 0;
7
+ let starColumns = [];
8
+ let starMaxMin = 0;
9
+ let starMaxMax = 0;
10
+ let fixedColumns = [];
11
+ let initial_availableWidth = availableWidth;
12
+
13
+ columns.forEach(column => {
15
14
  if (isAutoColumn(column)) {
16
15
  autoColumns.push(column);
17
16
  autoMin += column._minWidth;
@@ -25,16 +24,16 @@ function buildColumnWidths(columns, availableWidth, offsetTotal = 0, tableNode)
25
24
  }
26
25
  });
27
26
 
28
- fixedColumns.forEach(function (col, colIndex) {
27
+ fixedColumns.forEach((col, colIndex) => {
29
28
  // width specified as %
30
29
  if (isString(col.width) && /\d+%/.test(col.width)) {
31
30
  // In tables we have to take into consideration the reserved width for paddings and borders
32
- var reservedWidth = 0;
31
+ let reservedWidth = 0;
33
32
  if (tableNode) {
34
- var paddingLeft = tableNode._layout.paddingLeft(colIndex, tableNode);
35
- var paddingRight = tableNode._layout.paddingRight(colIndex, tableNode);
36
- var borderLeft = tableNode._layout.vLineWidth(colIndex, tableNode);
37
- var borderRight = tableNode._layout.vLineWidth(colIndex + 1, tableNode);
33
+ const paddingLeft = tableNode._layout.paddingLeft(colIndex, tableNode);
34
+ const paddingRight = tableNode._layout.paddingRight(colIndex, tableNode);
35
+ const borderLeft = tableNode._layout.vLineWidth(colIndex, tableNode);
36
+ const borderRight = tableNode._layout.vLineWidth(colIndex + 1, tableNode);
38
37
  if (colIndex === 0) {
39
38
  // first column assumes whole borderLeft and half of border right
40
39
  reservedWidth = paddingLeft + paddingRight + borderLeft + (borderRight / 2);
@@ -48,7 +47,7 @@ function buildColumnWidths(columns, availableWidth, offsetTotal = 0, tableNode)
48
47
  reservedWidth = paddingLeft + paddingRight + (borderLeft / 2) + (borderRight / 2);
49
48
  }
50
49
  }
51
- var totalAvailableWidth = initial_availableWidth + offsetTotal;
50
+ const totalAvailableWidth = initial_availableWidth + offsetTotal;
52
51
  col.width = (parseFloat(col.width) * totalAvailableWidth / 100) - reservedWidth;
53
52
  }
54
53
  if (col.width < (col._minWidth) && col.elasticWidth) {
@@ -63,43 +62,43 @@ function buildColumnWidths(columns, availableWidth, offsetTotal = 0, tableNode)
63
62
  // http://www.freesoft.org/CIE/RFC/1942/18.htm
64
63
  // http://www.w3.org/TR/CSS2/tables.html#width-layout
65
64
  // http://dev.w3.org/csswg/css3-tables-algorithms/Overview.src.htm
66
- var minW = autoMin + starMaxMin * starColumns.length;
67
- var maxW = autoMax + starMaxMax * starColumns.length;
65
+ let minW = autoMin + starMaxMin * starColumns.length;
66
+ let maxW = autoMax + starMaxMax * starColumns.length;
68
67
  if (minW >= availableWidth) {
69
68
  // case 1 - there's no way to fit all columns within available width
70
69
  // that's actually pretty bad situation with PDF as we have no horizontal scroll
71
70
  // no easy workaround (unless we decide, in the future, to split single words)
72
71
  // currently we simply use minWidths for all columns
73
- autoColumns.forEach(function (col) {
72
+ autoColumns.forEach(col => {
74
73
  col._calcWidth = col._minWidth;
75
74
  });
76
75
 
77
- starColumns.forEach(function (col) {
76
+ starColumns.forEach(col => {
78
77
  col._calcWidth = starMaxMin; // starMaxMin already contains padding
79
78
  });
80
79
  } else {
81
80
  if (maxW < availableWidth) {
82
81
  // case 2 - we can fit rest of the table within available space
83
- autoColumns.forEach(function (col) {
82
+ autoColumns.forEach(col => {
84
83
  col._calcWidth = col._maxWidth;
85
84
  availableWidth -= col._calcWidth;
86
85
  });
87
86
  } else {
88
87
  // maxW is too large, but minW fits within available width
89
- var W = availableWidth - minW;
90
- var D = maxW - minW;
88
+ let W = availableWidth - minW;
89
+ let D = maxW - minW;
91
90
 
92
- autoColumns.forEach(function (col) {
93
- var d = col._maxWidth - col._minWidth;
91
+ autoColumns.forEach(col => {
92
+ let d = col._maxWidth - col._minWidth;
94
93
  col._calcWidth = col._minWidth + d * W / D;
95
94
  availableWidth -= col._calcWidth;
96
95
  });
97
96
  }
98
97
 
99
98
  if (starColumns.length > 0) {
100
- var starSize = availableWidth / starColumns.length;
99
+ let starSize = availableWidth / starColumns.length;
101
100
 
102
- starColumns.forEach(function (col) {
101
+ starColumns.forEach(col => {
103
102
  col._calcWidth = starSize;
104
103
  });
105
104
  }
@@ -116,13 +115,12 @@ function isStarColumn(column) {
116
115
 
117
116
  //TODO: refactor and reuse in measureTable
118
117
  function measureMinMax(columns) {
119
- var result = { min: 0, max: 0 };
120
-
121
- var maxStar = { min: 0, max: 0 };
122
- var starCount = 0;
118
+ let result = { min: 0, max: 0 };
119
+ let maxStar = { min: 0, max: 0 };
120
+ let starCount = 0;
123
121
 
124
- for (var i = 0, l = columns.length; i < l; i++) {
125
- var c = columns[i];
122
+ for (let i = 0, l = columns.length; i < l; i++) {
123
+ let c = columns[i];
126
124
 
127
125
  if (isStarColumn(c)) {
128
126
  maxStar.min = Math.max(maxStar.min, c._minWidth);
@@ -147,9 +145,8 @@ function measureMinMax(columns) {
147
145
 
148
146
  /**
149
147
  * Calculates column widths
150
- * @private
151
148
  */
152
- module.exports = {
149
+ export default {
153
150
  buildColumnWidths: buildColumnWidths,
154
151
  measureMinMax: measureMinMax,
155
152
  isAutoColumn: isAutoColumn,
@@ -0,0 +1,110 @@
1
+ import { isNumber } from './variableType';
2
+
3
+ function fontStringify(key, val) {
4
+ if (key === 'font') {
5
+ return 'font';
6
+ }
7
+ return val;
8
+ }
9
+
10
+ /**
11
+ * Convert node to readable string
12
+ *
13
+ * @param {object} node
14
+ * @returns {string}
15
+ */
16
+ export function stringifyNode(node) {
17
+ return JSON.stringify(node, fontStringify);
18
+ }
19
+
20
+ /**
21
+ * @param {object} node
22
+ * @returns {?string}
23
+ */
24
+ export function getNodeId(node) {
25
+ if (node.id) {
26
+ return node.id;
27
+ }
28
+
29
+ if (Array.isArray(node.text)) {
30
+ for (let n of node.text) {
31
+ let nodeId = getNodeId(n);
32
+ if (nodeId) {
33
+ return nodeId;
34
+ }
35
+ }
36
+ }
37
+
38
+ return null;
39
+ }
40
+
41
+ /**
42
+ * @param {object} node
43
+ * @param {object} styleStack object is instance of PDFDocument
44
+ * @returns {?Array}
45
+ */
46
+ export function getNodeMargin(node, styleStack) {
47
+ function processSingleMargins(node, currentMargin) {
48
+ if (node.marginLeft || node.marginTop || node.marginRight || node.marginBottom) {
49
+ return [
50
+ node.marginLeft || currentMargin[0] || 0,
51
+ node.marginTop || currentMargin[1] || 0,
52
+ node.marginRight || currentMargin[2] || 0,
53
+ node.marginBottom || currentMargin[3] || 0
54
+ ];
55
+ }
56
+ return currentMargin;
57
+ }
58
+
59
+ function flattenStyleArray(styleArray, styleStack) {
60
+ let flattenedStyles = {};
61
+ for (let i = styleArray.length - 1; i >= 0; i--) {
62
+ let styleName = styleArray[i];
63
+ let style = styleStack.styleDictionary[styleName];
64
+ for (let key in style) {
65
+ if (style.hasOwnProperty(key)) {
66
+ flattenedStyles[key] = style[key];
67
+ }
68
+ }
69
+ }
70
+ return flattenedStyles;
71
+ }
72
+
73
+ function convertMargin(margin) {
74
+ if (isNumber(margin)) {
75
+ margin = [margin, margin, margin, margin];
76
+ } else if (Array.isArray(margin)) {
77
+ if (margin.length === 2) {
78
+ margin = [margin[0], margin[1], margin[0], margin[1]];
79
+ }
80
+ }
81
+ return margin;
82
+ }
83
+
84
+ let margin = [undefined, undefined, undefined, undefined];
85
+
86
+ if (node.style) {
87
+ let styleArray = Array.isArray(node.style) ? node.style : [node.style];
88
+ let flattenedStyleArray = flattenStyleArray(styleArray, styleStack);
89
+
90
+ if (flattenedStyleArray) {
91
+ margin = processSingleMargins(flattenedStyleArray, margin);
92
+ }
93
+
94
+ if (flattenedStyleArray.margin) {
95
+ margin = convertMargin(flattenedStyleArray.margin);
96
+ }
97
+ }
98
+
99
+ margin = processSingleMargins(node, margin);
100
+
101
+ if (node.margin) {
102
+ margin = convertMargin(node.margin);
103
+ }
104
+
105
+ if (margin[0] === undefined && margin[1] === undefined && margin[2] === undefined && margin[3] === undefined) {
106
+ return null;
107
+ }
108
+
109
+ return margin;
110
+ }
@@ -0,0 +1,39 @@
1
+ export function pack(...args) {
2
+ let result = {};
3
+
4
+ for (let i = 0, l = args.length; i < l; i++) {
5
+ let obj = args[i];
6
+
7
+ if (obj) {
8
+ for (let key in obj) {
9
+ if (obj.hasOwnProperty(key)) {
10
+ result[key] = obj[key];
11
+ }
12
+ }
13
+ }
14
+ }
15
+
16
+ return result;
17
+ }
18
+
19
+ export function offsetVector(vector, x, y) {
20
+ switch (vector.type) {
21
+ case 'ellipse':
22
+ case 'rect':
23
+ vector.x += x;
24
+ vector.y += y;
25
+ break;
26
+ case 'line':
27
+ vector.x1 += x;
28
+ vector.x2 += x;
29
+ vector.y1 += y;
30
+ vector.y2 += y;
31
+ break;
32
+ case 'polyline':
33
+ for (let i = 0, l = vector.points.length; i < l; i++) {
34
+ vector.points[i].x += x;
35
+ vector.points[i].y += y;
36
+ }
37
+ break;
38
+ }
39
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @param {any} variable
3
+ * @returns {boolean}
4
+ */
5
+ export function isString(variable) {
6
+ return (typeof variable === 'string') || (variable instanceof String);
7
+ }
8
+
9
+ /**
10
+ * @param {any} variable
11
+ * @returns {boolean}
12
+ */
13
+ export function isNumber(variable) {
14
+ return (typeof variable === 'number') || (variable instanceof Number);
15
+ }
16
+
17
+ /**
18
+ * @param {any} variable
19
+ * @returns {boolean}
20
+ */
21
+ export function isPositiveInteger(variable) {
22
+ if (!isNumber(variable) || !Number.isInteger(variable) || variable <= 0) {
23
+ return false;
24
+ }
25
+ return true;
26
+ }
27
+
28
+ /**
29
+ * @param {any} variable
30
+ * @returns {boolean}
31
+ */
32
+ export function isObject(variable) {
33
+ return (variable !== null) && !Array.isArray(variable) && !isString(variable) && !isNumber(variable) && (typeof variable === 'object');
34
+ }
35
+
36
+ /**
37
+ * @param {any} variable
38
+ * @returns {boolean}
39
+ */
40
+ export function isEmptyObject(variable) {
41
+ return isObject(variable) && (Object.keys(variable).length === 0);
42
+ }
43
+
44
+ /**
45
+ * @param {any} variable
46
+ * @returns {boolean}
47
+ */
48
+ export function isValue(variable) {
49
+ return (variable !== undefined) && (variable !== null);
50
+ }
package/src/index.js ADDED
@@ -0,0 +1,16 @@
1
+ const pdfmakeBase = require('./base').default;
2
+ const OutputDocumentServer = require('./OutputDocumentServer').default;
3
+ const URLResolver = require('./URLResolver').default;
4
+
5
+ class pdfmake extends pdfmakeBase {
6
+ constructor() {
7
+ super();
8
+ this.urlResolver = new URLResolver(this.virtualfs);
9
+ }
10
+
11
+ _transformToDocument(doc) {
12
+ return new OutputDocumentServer(doc);
13
+ }
14
+ }
15
+
16
+ module.exports = new pdfmake();
package/src/qrEnc.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /*eslint no-unused-vars: ["error", {"args": "none"}]*/
2
2
  /*eslint no-redeclare: "off"*/
3
+ /*eslint no-throw-literal: "off"*/
3
4
 
4
5
  'use strict';
5
6
  /* qr.js -- QR code generator in Javascript (revision 2011-01-19)
@@ -355,7 +356,7 @@ var calculateecc = function (poly, genpoly) {
355
356
  var polylen = poly.length, genpolylen = genpoly.length;
356
357
  for (var i = 0; i < genpolylen; ++i)
357
358
  modulus.push(0);
358
- for (var i = 0; i < polylen; ) {
359
+ for (var i = 0; i < polylen;) {
359
360
  var quotient = GF256_INVMAP[modulus[i++]];
360
361
  if (quotient >= 0) {
361
362
  for (var j = 0; j < genpolylen; ++j) {
@@ -483,7 +484,7 @@ var makebasematrix = function (ver) {
483
484
  }
484
485
  }
485
486
 
486
- return {matrix: matrix, reserved: reserved};
487
+ return { matrix: matrix, reserved: reserved };
487
488
  };
488
489
 
489
490
  // fills the data portion (i.e. unmarked in reserved) of the matrix with given
@@ -590,7 +591,7 @@ var evaluatematrix = function (matrix) {
590
591
 
591
592
  // evaluate the current row
592
593
  groups = [0]; // the first empty group of white
593
- for (var j = 0; j < n; ) {
594
+ for (var j = 0; j < n;) {
594
595
  var k;
595
596
  for (k = 0; j < n && row[j]; ++k)
596
597
  ++j;
@@ -603,7 +604,7 @@ var evaluatematrix = function (matrix) {
603
604
 
604
605
  // evaluate the current column
605
606
  groups = [0];
606
- for (var j = 0; j < n; ) {
607
+ for (var j = 0; j < n;) {
607
608
  var k;
608
609
  for (k = 0; j < n && matrix[j][i]; ++k)
609
610
  ++j;
@@ -677,10 +678,14 @@ var generate = function (data, ver, mode, ecclevel, mask) {
677
678
  //
678
679
 
679
680
  function generateFrame(data, options) {
680
- var MODES = {'numeric': MODE_NUMERIC, 'alphanumeric': MODE_ALPHANUMERIC,
681
- 'octet': MODE_OCTET};
682
- var ECCLEVELS = {'L': ECCLEVEL_L, 'M': ECCLEVEL_M, 'Q': ECCLEVEL_Q,
683
- 'H': ECCLEVEL_H};
681
+ var MODES = {
682
+ 'numeric': MODE_NUMERIC, 'alphanumeric': MODE_ALPHANUMERIC,
683
+ 'octet': MODE_OCTET
684
+ };
685
+ var ECCLEVELS = {
686
+ 'L': ECCLEVEL_L, 'M': ECCLEVEL_M, 'Q': ECCLEVEL_Q,
687
+ 'H': ECCLEVEL_H
688
+ };
684
689
 
685
690
  options = options || {};
686
691
  var ver = options.version || -1;
@@ -786,6 +791,6 @@ function measure(node) {
786
791
  return node;
787
792
  }
788
793
 
789
- module.exports = {
794
+ export default {
790
795
  measure: measure
791
- };
796
+ };
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- module.exports = {
1
+ export default {
4
2
  '4A0': [4767.87, 6740.79],
5
3
  '2A0': [3370.39, 4767.87],
6
4
  A0: [2383.94, 3370.39],
@@ -0,0 +1,100 @@
1
+ /*eslint no-unused-vars: ["error", {"args": "none"}]*/
2
+
3
+ export {
4
+ tableLayouts,
5
+ defaultTableLayout
6
+ };
7
+
8
+ const tableLayouts = {
9
+ noBorders: {
10
+ hLineWidth(i) {
11
+ return 0;
12
+ },
13
+ vLineWidth(i) {
14
+ return 0;
15
+ },
16
+ paddingLeft(i) {
17
+ return i && 4 || 0;
18
+ },
19
+ paddingRight(i, node) {
20
+ return (i < node.table.widths.length - 1) ? 4 : 0;
21
+ }
22
+ },
23
+ headerLineOnly: {
24
+ hLineWidth(i, node) {
25
+ if (i === 0 || i === node.table.body.length) {
26
+ return 0;
27
+ }
28
+ return (i === node.table.headerRows) ? 2 : 0;
29
+ },
30
+ vLineWidth(i) {
31
+ return 0;
32
+ },
33
+ paddingLeft(i) {
34
+ return i === 0 ? 0 : 8;
35
+ },
36
+ paddingRight(i, node) {
37
+ return (i === node.table.widths.length - 1) ? 0 : 8;
38
+ }
39
+ },
40
+ lightHorizontalLines: {
41
+ hLineWidth(i, node) {
42
+ if (i === 0 || i === node.table.body.length) {
43
+ return 0;
44
+ }
45
+ return (i === node.table.headerRows) ? 2 : 1;
46
+ },
47
+ vLineWidth(i) {
48
+ return 0;
49
+ },
50
+ hLineColor(i) {
51
+ return i === 1 ? 'black' : '#aaa';
52
+ },
53
+ paddingLeft(i) {
54
+ return i === 0 ? 0 : 8;
55
+ },
56
+ paddingRight(i, node) {
57
+ return (i === node.table.widths.length - 1) ? 0 : 8;
58
+ }
59
+ }
60
+ };
61
+
62
+ const defaultTableLayout = {
63
+ hLineWidth(i, node) {
64
+ return 1;
65
+ },
66
+ vLineWidth(i, node) {
67
+ return 1;
68
+ },
69
+ hLineColor(i, node) {
70
+ return 'black';
71
+ },
72
+ vLineColor(i, node) {
73
+ return 'black';
74
+ },
75
+ hLineStyle(i, node) {
76
+ return null;
77
+ },
78
+ vLineStyle(i, node) {
79
+ return null;
80
+ },
81
+ paddingLeft(i, node) {
82
+ return 4;
83
+ },
84
+ paddingRight(i, node) {
85
+ return 4;
86
+ },
87
+ paddingTop(i, node) {
88
+ return 2;
89
+ },
90
+ paddingBottom(i, node) {
91
+ return 2;
92
+ },
93
+ fillColor(i, node) {
94
+ return null;
95
+ },
96
+ fillOpacity(i, node) {
97
+ return 1;
98
+ },
99
+ defaultBorder: true
100
+ };