pdfmake 0.3.3 → 0.3.5

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 (93) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/LICENSE +21 -21
  3. package/README.md +76 -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 +65042 -64408
  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/DocMeasure.js +9 -6
  22. package/js/DocumentContext.js +236 -7
  23. package/js/ElementWriter.js +42 -16
  24. package/js/LayoutBuilder.js +277 -86
  25. package/js/Line.js +16 -16
  26. package/js/OutputDocument.js +10 -10
  27. package/js/OutputDocumentServer.js +3 -3
  28. package/js/PDFDocument.js +6 -4
  29. package/js/PageElementWriter.js +124 -11
  30. package/js/Printer.js +28 -28
  31. package/js/Renderer.js +53 -8
  32. package/js/SVGMeasure.js +14 -12
  33. package/js/StyleContextStack.js +48 -48
  34. package/js/TableProcessor.js +15 -5
  35. package/js/TextBreaker.js +17 -17
  36. package/js/TextInlines.js +33 -33
  37. package/js/URLResolver.js +3 -1
  38. package/js/base.js +4 -4
  39. package/js/browser-extensions/OutputDocumentBrowser.js +24 -24
  40. package/js/columnCalculator.js +2 -2
  41. package/js/helpers/node.js +14 -15
  42. package/js/helpers/variableType.js +18 -18
  43. package/js/qrEnc.js +38 -38
  44. package/js/virtual-fs.js +11 -11
  45. package/package.json +10 -10
  46. package/src/3rd-party/svg-to-pdfkit/LICENSE +9 -9
  47. package/src/3rd-party/svg-to-pdfkit/source.js +2745 -2745
  48. package/src/3rd-party/svg-to-pdfkit.js +3 -3
  49. package/src/DocMeasure.js +749 -745
  50. package/src/DocPreprocessor.js +283 -283
  51. package/src/DocumentContext.js +579 -338
  52. package/src/ElementWriter.js +441 -417
  53. package/src/LayoutBuilder.js +1470 -1262
  54. package/src/Line.js +114 -114
  55. package/src/OutputDocument.js +64 -64
  56. package/src/OutputDocumentServer.js +32 -32
  57. package/src/PDFDocument.js +174 -174
  58. package/src/PageElementWriter.js +306 -179
  59. package/src/PageSize.js +53 -53
  60. package/src/Printer.js +306 -306
  61. package/src/Renderer.js +458 -409
  62. package/src/SVGMeasure.js +109 -109
  63. package/src/StyleContextStack.js +208 -208
  64. package/src/TableProcessor.js +616 -602
  65. package/src/TextBreaker.js +168 -168
  66. package/src/TextDecorator.js +175 -175
  67. package/src/TextInlines.js +224 -224
  68. package/src/URLResolver.js +43 -43
  69. package/src/base.js +70 -70
  70. package/src/browser-extensions/OutputDocumentBrowser.js +80 -80
  71. package/src/browser-extensions/fonts/Roboto.js +27 -27
  72. package/src/browser-extensions/index.js +55 -55
  73. package/src/browser-extensions/pdfMake.js +1 -1
  74. package/src/browser-extensions/standard-fonts/Courier.js +27 -27
  75. package/src/browser-extensions/standard-fonts/Helvetica.js +27 -27
  76. package/src/browser-extensions/standard-fonts/Symbol.js +21 -21
  77. package/src/browser-extensions/standard-fonts/Times.js +27 -27
  78. package/src/browser-extensions/standard-fonts/ZapfDingbats.js +21 -21
  79. package/src/browser-extensions/virtual-fs-cjs.js +1 -1
  80. package/src/columnCalculator.js +154 -154
  81. package/src/helpers/node.js +134 -136
  82. package/src/helpers/tools.js +44 -44
  83. package/src/helpers/variableType.js +50 -50
  84. package/src/index.js +16 -16
  85. package/src/qrEnc.js +796 -796
  86. package/src/standardPageSizes.js +52 -52
  87. package/src/tableLayouts.js +100 -100
  88. package/src/virtual-fs.js +66 -66
  89. package/standard-fonts/Courier.js +8 -8
  90. package/standard-fonts/Helvetica.js +8 -8
  91. package/standard-fonts/Symbol.js +5 -5
  92. package/standard-fonts/Times.js +8 -8
  93. package/standard-fonts/ZapfDingbats.js +5 -5
@@ -1,52 +1,52 @@
1
- export default {
2
- '4A0': [4767.87, 6740.79],
3
- '2A0': [3370.39, 4767.87],
4
- A0: [2383.94, 3370.39],
5
- A1: [1683.78, 2383.94],
6
- A2: [1190.55, 1683.78],
7
- A3: [841.89, 1190.55],
8
- A4: [595.28, 841.89],
9
- A5: [419.53, 595.28],
10
- A6: [297.64, 419.53],
11
- A7: [209.76, 297.64],
12
- A8: [147.40, 209.76],
13
- A9: [104.88, 147.40],
14
- A10: [73.70, 104.88],
15
- B0: [2834.65, 4008.19],
16
- B1: [2004.09, 2834.65],
17
- B2: [1417.32, 2004.09],
18
- B3: [1000.63, 1417.32],
19
- B4: [708.66, 1000.63],
20
- B5: [498.90, 708.66],
21
- B6: [354.33, 498.90],
22
- B7: [249.45, 354.33],
23
- B8: [175.75, 249.45],
24
- B9: [124.72, 175.75],
25
- B10: [87.87, 124.72],
26
- C0: [2599.37, 3676.54],
27
- C1: [1836.85, 2599.37],
28
- C2: [1298.27, 1836.85],
29
- C3: [918.43, 1298.27],
30
- C4: [649.13, 918.43],
31
- C5: [459.21, 649.13],
32
- C6: [323.15, 459.21],
33
- C7: [229.61, 323.15],
34
- C8: [161.57, 229.61],
35
- C9: [113.39, 161.57],
36
- C10: [79.37, 113.39],
37
- RA0: [2437.80, 3458.27],
38
- RA1: [1729.13, 2437.80],
39
- RA2: [1218.90, 1729.13],
40
- RA3: [864.57, 1218.90],
41
- RA4: [609.45, 864.57],
42
- SRA0: [2551.18, 3628.35],
43
- SRA1: [1814.17, 2551.18],
44
- SRA2: [1275.59, 1814.17],
45
- SRA3: [907.09, 1275.59],
46
- SRA4: [637.80, 907.09],
47
- EXECUTIVE: [521.86, 756.00],
48
- FOLIO: [612.00, 936.00],
49
- LEGAL: [612.00, 1008.00],
50
- LETTER: [612.00, 792.00],
51
- TABLOID: [792.00, 1224.00]
52
- };
1
+ export default {
2
+ '4A0': [4767.87, 6740.79],
3
+ '2A0': [3370.39, 4767.87],
4
+ A0: [2383.94, 3370.39],
5
+ A1: [1683.78, 2383.94],
6
+ A2: [1190.55, 1683.78],
7
+ A3: [841.89, 1190.55],
8
+ A4: [595.28, 841.89],
9
+ A5: [419.53, 595.28],
10
+ A6: [297.64, 419.53],
11
+ A7: [209.76, 297.64],
12
+ A8: [147.40, 209.76],
13
+ A9: [104.88, 147.40],
14
+ A10: [73.70, 104.88],
15
+ B0: [2834.65, 4008.19],
16
+ B1: [2004.09, 2834.65],
17
+ B2: [1417.32, 2004.09],
18
+ B3: [1000.63, 1417.32],
19
+ B4: [708.66, 1000.63],
20
+ B5: [498.90, 708.66],
21
+ B6: [354.33, 498.90],
22
+ B7: [249.45, 354.33],
23
+ B8: [175.75, 249.45],
24
+ B9: [124.72, 175.75],
25
+ B10: [87.87, 124.72],
26
+ C0: [2599.37, 3676.54],
27
+ C1: [1836.85, 2599.37],
28
+ C2: [1298.27, 1836.85],
29
+ C3: [918.43, 1298.27],
30
+ C4: [649.13, 918.43],
31
+ C5: [459.21, 649.13],
32
+ C6: [323.15, 459.21],
33
+ C7: [229.61, 323.15],
34
+ C8: [161.57, 229.61],
35
+ C9: [113.39, 161.57],
36
+ C10: [79.37, 113.39],
37
+ RA0: [2437.80, 3458.27],
38
+ RA1: [1729.13, 2437.80],
39
+ RA2: [1218.90, 1729.13],
40
+ RA3: [864.57, 1218.90],
41
+ RA4: [609.45, 864.57],
42
+ SRA0: [2551.18, 3628.35],
43
+ SRA1: [1814.17, 2551.18],
44
+ SRA2: [1275.59, 1814.17],
45
+ SRA3: [907.09, 1275.59],
46
+ SRA4: [637.80, 907.09],
47
+ EXECUTIVE: [521.86, 756.00],
48
+ FOLIO: [612.00, 936.00],
49
+ LEGAL: [612.00, 1008.00],
50
+ LETTER: [612.00, 792.00],
51
+ TABLOID: [792.00, 1224.00]
52
+ };
@@ -1,100 +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
- };
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
+ };
package/src/virtual-fs.js CHANGED
@@ -1,66 +1,66 @@
1
- const normalizeFilename = filename => {
2
- if (filename.indexOf(__dirname) === 0) {
3
- filename = filename.substring(__dirname.length);
4
- }
5
-
6
- if (filename.indexOf('/') === 0) {
7
- filename = filename.substring(1);
8
- }
9
-
10
- return filename;
11
- };
12
-
13
- class VirtualFileSystem {
14
- constructor() {
15
- this.storage = {};
16
- }
17
-
18
- /**
19
- * @param {string} filename
20
- * @returns {boolean}
21
- */
22
- existsSync(filename) {
23
- const normalizedFilename = normalizeFilename(filename);
24
- return typeof this.storage[normalizedFilename] !== 'undefined';
25
- }
26
-
27
- /**
28
- * @param {string} filename
29
- * @param {?string|?object} options
30
- * @returns {string|Buffer}
31
- */
32
- readFileSync(filename, options) {
33
- const normalizedFilename = normalizeFilename(filename);
34
- const encoding = typeof options === 'object' ? options.encoding : options;
35
-
36
- if (!this.existsSync(normalizedFilename)) {
37
- throw new Error(`File '${normalizedFilename}' not found in virtual file system`);
38
- }
39
-
40
- const buffer = this.storage[normalizedFilename];
41
- if (encoding) {
42
- return buffer.toString(encoding);
43
- }
44
-
45
- return buffer;
46
- }
47
-
48
- /**
49
- * @param {string} filename
50
- * @param {string|Buffer} content
51
- * @param {?string|?object} options
52
- */
53
- writeFileSync(filename, content, options) {
54
- const normalizedFilename = normalizeFilename(filename);
55
- const encoding = typeof options === 'object' ? options.encoding : options;
56
-
57
- if (!content && !options) {
58
- throw new Error('No content');
59
- }
60
-
61
- this.storage[normalizedFilename] = encoding || typeof content === 'string' ? new Buffer(content, encoding) : content;
62
- }
63
-
64
- }
65
-
66
- export default new VirtualFileSystem();
1
+ const normalizeFilename = filename => {
2
+ if (filename.indexOf(__dirname) === 0) {
3
+ filename = filename.substring(__dirname.length);
4
+ }
5
+
6
+ if (filename.indexOf('/') === 0) {
7
+ filename = filename.substring(1);
8
+ }
9
+
10
+ return filename;
11
+ };
12
+
13
+ class VirtualFileSystem {
14
+ constructor() {
15
+ this.storage = {};
16
+ }
17
+
18
+ /**
19
+ * @param {string} filename
20
+ * @returns {boolean}
21
+ */
22
+ existsSync(filename) {
23
+ const normalizedFilename = normalizeFilename(filename);
24
+ return typeof this.storage[normalizedFilename] !== 'undefined';
25
+ }
26
+
27
+ /**
28
+ * @param {string} filename
29
+ * @param {?string|?object} options
30
+ * @returns {string|Buffer}
31
+ */
32
+ readFileSync(filename, options) {
33
+ const normalizedFilename = normalizeFilename(filename);
34
+ const encoding = typeof options === 'object' ? options.encoding : options;
35
+
36
+ if (!this.existsSync(normalizedFilename)) {
37
+ throw new Error(`File '${normalizedFilename}' not found in virtual file system`);
38
+ }
39
+
40
+ const buffer = this.storage[normalizedFilename];
41
+ if (encoding) {
42
+ return buffer.toString(encoding);
43
+ }
44
+
45
+ return buffer;
46
+ }
47
+
48
+ /**
49
+ * @param {string} filename
50
+ * @param {string|Buffer} content
51
+ * @param {?string|?object} options
52
+ */
53
+ writeFileSync(filename, content, options) {
54
+ const normalizedFilename = normalizeFilename(filename);
55
+ const encoding = typeof options === 'object' ? options.encoding : options;
56
+
57
+ if (!content && !options) {
58
+ throw new Error('No content');
59
+ }
60
+
61
+ this.storage[normalizedFilename] = encoding || typeof content === 'string' ? new Buffer(content, encoding) : content;
62
+ }
63
+
64
+ }
65
+
66
+ export default new VirtualFileSystem();
@@ -1,8 +1,8 @@
1
- module.exports = {
2
- Courier: {
3
- normal: 'Courier',
4
- bold: 'Courier-Bold',
5
- italics: 'Courier-Oblique',
6
- bolditalics: 'Courier-BoldOblique'
7
- }
8
- };
1
+ module.exports = {
2
+ Courier: {
3
+ normal: 'Courier',
4
+ bold: 'Courier-Bold',
5
+ italics: 'Courier-Oblique',
6
+ bolditalics: 'Courier-BoldOblique'
7
+ }
8
+ };
@@ -1,8 +1,8 @@
1
- module.exports = {
2
- Helvetica: {
3
- normal: 'Helvetica',
4
- bold: 'Helvetica-Bold',
5
- italics: 'Helvetica-Oblique',
6
- bolditalics: 'Helvetica-BoldOblique'
7
- }
8
- };
1
+ module.exports = {
2
+ Helvetica: {
3
+ normal: 'Helvetica',
4
+ bold: 'Helvetica-Bold',
5
+ italics: 'Helvetica-Oblique',
6
+ bolditalics: 'Helvetica-BoldOblique'
7
+ }
8
+ };
@@ -1,5 +1,5 @@
1
- module.exports = {
2
- Symbol: {
3
- normal: 'Symbol'
4
- }
5
- };
1
+ module.exports = {
2
+ Symbol: {
3
+ normal: 'Symbol'
4
+ }
5
+ };
@@ -1,8 +1,8 @@
1
- module.exports = {
2
- Times: {
3
- normal: 'Times-Roman',
4
- bold: 'Times-Bold',
5
- italics: 'Times-Italic',
6
- bolditalics: 'Times-BoldItalic'
7
- }
8
- };
1
+ module.exports = {
2
+ Times: {
3
+ normal: 'Times-Roman',
4
+ bold: 'Times-Bold',
5
+ italics: 'Times-Italic',
6
+ bolditalics: 'Times-BoldItalic'
7
+ }
8
+ };
@@ -1,5 +1,5 @@
1
- module.exports = {
2
- ZapfDingbats: {
3
- normal: 'ZapfDingbats'
4
- }
5
- };
1
+ module.exports = {
2
+ ZapfDingbats: {
3
+ normal: 'ZapfDingbats'
4
+ }
5
+ };