pdfmake-acroforms 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 (115) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/LICENSE +21 -0
  3. package/README.md +75 -0
  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 +67806 -0
  10. package/build/pdfmake.js.map +1 -0
  11. package/build/pdfmake.min.js +3 -0
  12. package/build/pdfmake.min.js.map +1 -0
  13. package/build/standard-fonts/Courier.js +27 -0
  14. package/build/standard-fonts/Helvetica.js +27 -0
  15. package/build/standard-fonts/Symbol.js +21 -0
  16. package/build/standard-fonts/Times.js +27 -0
  17. package/build/standard-fonts/ZapfDingbats.js +21 -0
  18. package/build/vfs_fonts.js +6 -0
  19. package/build-vfs.js +44 -0
  20. package/fonts/Roboto/Roboto-Italic.ttf +0 -0
  21. package/fonts/Roboto/Roboto-Medium.ttf +0 -0
  22. package/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
  23. package/fonts/Roboto/Roboto-Regular.ttf +0 -0
  24. package/fonts/Roboto.js +8 -0
  25. package/js/3rd-party/svg-to-pdfkit/source.js +3823 -0
  26. package/js/3rd-party/svg-to-pdfkit.js +7 -0
  27. package/js/DocMeasure.js +675 -0
  28. package/js/DocPreprocessor.js +258 -0
  29. package/js/DocumentContext.js +310 -0
  30. package/js/ElementWriter.js +399 -0
  31. package/js/LayoutBuilder.js +1202 -0
  32. package/js/Line.js +101 -0
  33. package/js/OutputDocument.js +64 -0
  34. package/js/OutputDocumentServer.js +29 -0
  35. package/js/PDFDocument.js +145 -0
  36. package/js/PageElementWriter.js +164 -0
  37. package/js/PageSize.js +74 -0
  38. package/js/Printer.js +288 -0
  39. package/js/Renderer.js +513 -0
  40. package/js/SVGMeasure.js +92 -0
  41. package/js/StyleContextStack.js +191 -0
  42. package/js/TableProcessor.js +562 -0
  43. package/js/TextBreaker.js +179 -0
  44. package/js/TextDecorator.js +152 -0
  45. package/js/TextInlines.js +212 -0
  46. package/js/URLResolver.js +43 -0
  47. package/js/base.js +59 -0
  48. package/js/browser-extensions/OutputDocumentBrowser.js +82 -0
  49. package/js/browser-extensions/fonts/Roboto.js +38 -0
  50. package/js/browser-extensions/index.js +53 -0
  51. package/js/browser-extensions/pdfMake.js +3 -0
  52. package/js/browser-extensions/standard-fonts/Courier.js +38 -0
  53. package/js/browser-extensions/standard-fonts/Helvetica.js +38 -0
  54. package/js/browser-extensions/standard-fonts/Symbol.js +23 -0
  55. package/js/browser-extensions/standard-fonts/Times.js +38 -0
  56. package/js/browser-extensions/standard-fonts/ZapfDingbats.js +23 -0
  57. package/js/browser-extensions/virtual-fs-cjs.js +3 -0
  58. package/js/columnCalculator.js +148 -0
  59. package/js/helpers/node.js +122 -0
  60. package/js/helpers/tools.js +46 -0
  61. package/js/helpers/variableType.js +59 -0
  62. package/js/index.js +15 -0
  63. package/js/qrEnc.js +721 -0
  64. package/js/standardPageSizes.js +56 -0
  65. package/js/tableLayouts.js +98 -0
  66. package/js/virtual-fs.js +60 -0
  67. package/package.json +94 -0
  68. package/src/3rd-party/svg-to-pdfkit/LICENSE +9 -0
  69. package/src/3rd-party/svg-to-pdfkit/source.js +2745 -0
  70. package/src/3rd-party/svg-to-pdfkit.js +3 -0
  71. package/src/DocMeasure.js +768 -0
  72. package/src/DocPreprocessor.js +289 -0
  73. package/src/DocumentContext.js +345 -0
  74. package/src/ElementWriter.js +468 -0
  75. package/src/LayoutBuilder.js +1366 -0
  76. package/src/Line.js +108 -0
  77. package/src/OutputDocument.js +64 -0
  78. package/src/OutputDocumentServer.js +32 -0
  79. package/src/PDFDocument.js +178 -0
  80. package/src/PageElementWriter.js +191 -0
  81. package/src/PageSize.js +53 -0
  82. package/src/Printer.js +306 -0
  83. package/src/Renderer.js +546 -0
  84. package/src/SVGMeasure.js +109 -0
  85. package/src/StyleContextStack.js +208 -0
  86. package/src/TableProcessor.js +620 -0
  87. package/src/TextBreaker.js +181 -0
  88. package/src/TextDecorator.js +175 -0
  89. package/src/TextInlines.js +229 -0
  90. package/src/URLResolver.js +43 -0
  91. package/src/base.js +70 -0
  92. package/src/browser-extensions/OutputDocumentBrowser.js +80 -0
  93. package/src/browser-extensions/fonts/Roboto.js +27 -0
  94. package/src/browser-extensions/index.js +55 -0
  95. package/src/browser-extensions/pdfMake.js +1 -0
  96. package/src/browser-extensions/standard-fonts/Courier.js +27 -0
  97. package/src/browser-extensions/standard-fonts/Helvetica.js +27 -0
  98. package/src/browser-extensions/standard-fonts/Symbol.js +21 -0
  99. package/src/browser-extensions/standard-fonts/Times.js +27 -0
  100. package/src/browser-extensions/standard-fonts/ZapfDingbats.js +21 -0
  101. package/src/browser-extensions/virtual-fs-cjs.js +1 -0
  102. package/src/columnCalculator.js +154 -0
  103. package/src/helpers/node.js +134 -0
  104. package/src/helpers/tools.js +44 -0
  105. package/src/helpers/variableType.js +50 -0
  106. package/src/index.js +16 -0
  107. package/src/qrEnc.js +796 -0
  108. package/src/standardPageSizes.js +52 -0
  109. package/src/tableLayouts.js +100 -0
  110. package/src/virtual-fs.js +66 -0
  111. package/standard-fonts/Courier.js +8 -0
  112. package/standard-fonts/Helvetica.js +8 -0
  113. package/standard-fonts/Symbol.js +5 -0
  114. package/standard-fonts/Times.js +8 -0
  115. package/standard-fonts/ZapfDingbats.js +5 -0
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = void 0;
5
+ var _variableType = require("./helpers/variableType");
6
+ /**
7
+ * Used for style inheritance and style overrides
8
+ */
9
+ class StyleContextStack {
10
+ /**
11
+ * @param {object} styleDictionary named styles dictionary
12
+ * @param {object} defaultStyle optional default style definition
13
+ */
14
+ constructor(styleDictionary, defaultStyle = {}) {
15
+ this.styleDictionary = styleDictionary;
16
+ this.defaultStyle = defaultStyle;
17
+ this.styleOverrides = [];
18
+ }
19
+
20
+ /**
21
+ * Creates cloned version of current stack
22
+ *
23
+ * @returns {StyleContextStack} current stack snapshot
24
+ */
25
+ clone() {
26
+ let stack = new StyleContextStack(this.styleDictionary, this.defaultStyle);
27
+ this.styleOverrides.forEach(item => {
28
+ stack.styleOverrides.push(item);
29
+ });
30
+ return stack;
31
+ }
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
38
+ */
39
+ push(styleNameOrOverride) {
40
+ this.styleOverrides.push(styleNameOrOverride);
41
+ }
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)
48
+ */
49
+ pop(howMany = 1) {
50
+ while (howMany-- > 0) {
51
+ this.styleOverrides.pop();
52
+ }
53
+ }
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
62
+ */
63
+ autopush(item) {
64
+ if ((0, _variableType.isString)(item)) {
65
+ return 0;
66
+ }
67
+ if (typeof item.section !== 'undefined') {
68
+ // section node not support style overrides
69
+ return 0;
70
+ }
71
+ let styleNames = [];
72
+ if (item.style) {
73
+ if (Array.isArray(item.style)) {
74
+ styleNames = item.style;
75
+ } else {
76
+ styleNames = [item.style];
77
+ }
78
+ }
79
+ for (let i = 0, l = styleNames.length; i < l; i++) {
80
+ this.push(styleNames[i]);
81
+ }
82
+
83
+ // rather than spend significant time making a styleOverrideObject, just add item
84
+ this.push(item);
85
+ return styleNames.length + 1;
86
+ }
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
95
+ */
96
+ auto(item, callback) {
97
+ let pushedItems = this.autopush(item);
98
+ let result = callback();
99
+ if (pushedItems > 0) {
100
+ this.pop(pushedItems);
101
+ }
102
+ return result;
103
+ }
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
110
+ */
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
+ };
135
+ if (this.styleOverrides) {
136
+ for (let i = this.styleOverrides.length - 1; i >= 0; i--) {
137
+ let item = this.styleOverrides[i];
138
+ if ((0, _variableType.isString)(item)) {
139
+ // named-style-override
140
+ let value = getStylePropertyFromStyle(item, property);
141
+ if ((0, _variableType.isValue)(value)) {
142
+ return value;
143
+ }
144
+ } else if ((0, _variableType.isValue)(item[property])) {
145
+ // style-overrides-object
146
+ return item[property];
147
+ }
148
+ }
149
+ }
150
+ return this.defaultStyle && this.defaultStyle[property];
151
+ }
152
+
153
+ /**
154
+ * @param {object} item
155
+ * @param {StyleContextStack} styleContextStack
156
+ * @param {string} property
157
+ * @param {any} defaultValue
158
+ * @returns {any}
159
+ */
160
+ static getStyleProperty(item, styleContextStack, property, defaultValue) {
161
+ let value;
162
+ if ((0, _variableType.isValue)(item[property])) {
163
+ // item defines this property
164
+ return item[property];
165
+ }
166
+ if (!styleContextStack) {
167
+ return defaultValue;
168
+ }
169
+ styleContextStack.auto(item, () => {
170
+ value = styleContextStack.getProperty(property);
171
+ });
172
+ return (0, _variableType.isValue)(value) ? value : defaultValue;
173
+ }
174
+
175
+ /**
176
+ * @param {object} source
177
+ * @param {object} destination
178
+ * @returns {object}
179
+ */
180
+ static copyStyle(source = {}, destination = {}) {
181
+ // TODO: default style to source
182
+
183
+ for (let key in source) {
184
+ if (key != 'text' && source.hasOwnProperty(key)) {
185
+ destination[key] = source[key];
186
+ }
187
+ }
188
+ return destination;
189
+ }
190
+ }
191
+ var _default = exports.default = StyleContextStack;